|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
nprioleau Smarty Rookie
Joined: 15 Feb 2016 Posts: 7
|
Posted: Fri Mar 04, 2016 11:42 am Post subject: Using jQuery with smarty |
|
|
I want to use an editable grid but am having difficulty understanding how to implement it. I am very new to smarty and am a bit of a hack developer (personal applications ONLY). Must I declare my javascript functions in the template or in the _head? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Mar 04, 2016 1:18 pm Post subject: |
|
|
Wherever you want to do it.
JS works on client, Smarty works on server. From Smarty's point of view, your "functions" is just another text it needs to put on a page. |
|
Back to top |
|
nprioleau Smarty Rookie
Joined: 15 Feb 2016 Posts: 7
|
Posted: Mon Mar 07, 2016 6:26 am Post subject: |
|
|
Thank you. Is there any reason why a function would not work? I have put my function inside my template. When I click a button that calls the function, nothing happens.
Code: |
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New User</a>
{literal}
var url;
function newUser(){
$('#dlg').dialog('open').dialog('center').dialog('setTitle','New User');
$('#fm').form('clear');
url = 'save_user.php';
}
{/literal} |
|
|
Back to top |
|
nprioleau Smarty Rookie
Joined: 15 Feb 2016 Posts: 7
|
Posted: Mon Mar 07, 2016 6:50 am Post subject: |
|
|
I have managed to solve one aspect but the code for displaying my grid is still not being called. I have successfully returned a json array:
Code: | [{"salesd_ID":"1","salesd_salesID":"242","salesd_productID":"2","salesd_unitPrice":null,"salesd_qty":"2000","salesd_total":null,"salesd_comments":null},{"salesd_ID":"2","salesd_salesID":"242","salesd_productID":"3","salesd_unitPrice":null,"salesd_qty":"1500","salesd_total":null,"salesd_comments":null}]
|
And have this code to display it:
Code: |
<table id="dg" title="Sales Order Details" class="easyui-datagrid" style="width:700px;height:250px"
toolbar="#toolbar" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="salesd_productID" width="50">Product Name</th>
<th field="salesd_unitPrice" width="50">Unit Price</th>
<th field="salesd_qty" width="50">Quantity</th>
<th field="salesd_total" width="50">Total</th>
</tr>
</thead>
</table>
|
I can't see anything obvious.[/code] |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|