I have following jQuery script in application.js for Rails 3 application. I like to make url parameter to be dynamically generated. For example id value in people controller needs to generated base on a parameter from the controller. The problem is that jQuery script in application.js is static so i'm not sure how to make a section of the code to be dynamic i.e. to accept parameters from the controller. please let me know if have some ideas and i greatly appreciated.
jQuery("#paactions").jqGrid({
url: 'people/123456/pa.json',
datatype: 'json',
height: 'auto',
pager: false,
viewrecords: true,
colNames: ['id', 'indexno', 'site', 'effective', 'processed', 'code', 'action',
'officer', 'remarks'],
colModel: [
{name: 'id', index: 'key', width:50, key:true, hidden:true},
{name: 'indexno', index: 'indexno', width:50, hidden:true},
{name: 'site', index: 'site', width:4, hidden:false},
{name: 'effective', index: 'effective', width:7},
{name: 'processed', index: 'processed', width:7},
{name: 'code', index: 'code', width:5, resizable: false, sortable:false},
{name: 'action', index: 'action', width:15},
{name: 'officer', index: 'officer', width:10},
{name: 'remarks', index: 'remarks', width:50},
],
caption: "Personnel Actions",
autowidth: true,
//width: 180,
rowNum: 20
});
application.js? There are different ways do do this it would be interesting to know which one you use. You can useurl: myurl. The problem is only where it is better for you to set the value ofmyurlvariable.