开发者

Rails How to render dynamic javascript

开发者 https://www.devze.com 2023-02-17 04:45 出处:网络
I\'m trying to use gridify grid control from: https://github.com/linoj/gridify I did everything as said in https://github.com/linoj/gridify but I\'m getting javascript code on my view page. any ideas

I'm trying to use gridify grid control from: https://github.com/linoj/gridify

I did everything as said in https://github.com/linoj/gridify but I'm getting javascript code on my view page. any ideas? I've written <%= @grid %> on my index.html.rb. it looks like rails escapes javascript tags, i'm seeing this code on the view page instead of actual grid:

<script type="text/javascript"> function gridify_fluid_recalc_width(){ if (grids = jQuery('.fluid.ui-jqgrid-btable:visible')) { grids.each(function(index) { gridId = jQuery(this).attr('id'); gridParentWidth = jQuery('#gbox_' + gridId).parent().width(); jQuery('#' + gridId).setGridWidth(gridParent开发者_JAVA技巧Width); }); } }; jQuery(window).bind('resize', gridify_fluid_recalc_width); function gridify_action_error_handler(r, data, action){ if (r.responseText != '') { return [false, r.responseText]; } else { return true; } } jQuery(document).ready(function(){ grid = jQuery("#contacts_grid").jqGrid({"beforeSelectRow": function(){ false; },"resizeStop": gridify_fluid_recalc_width,"autowidth":true,"rowNum":-1,"gridview":true,"restful":true,"url":"/contacts","hidegrid":false,"xmlReader":{"total":"contacts>total_pages","row":"contact","id":"id","root":"contacts","page":"contacts>page","records":"contacts>total_records","repeatitems":false},"forceFit":true,"datatype":"xml","postData":{"grid":"grid"},"colModel":[{"label":"Id","name":"id","sorttype":"integer","align":"right","index":"id","hidden":true},{"label":"Title","name":"title","sorttype":"text","index":"title"},{"label":"Address","name":"address","sorttype":"text","index":"address"},{"label":"Phone1","name":"phone1","sorttype":"text","index":"phone1"},{"label":"Phone2","name":"phone2","sorttype":"text","index":"phone2"},{"label":"Fax","name":"fax","sorttype":"text","index":"fax"},{"label":"Registration Number","name":"registration_number","sorttype":"text","index":"registration_number"},{"label":"Identity Number","name":"identity_number","sorttype":"text","index":"identity_number"},{"label":"National Code","name":"national_code","sorttype":"text","index":"national_code"},{"label":"Father Name","name":"father_name","sorttype":"text","index":"father_name"},{"label":"Birthday","name":"birthday","sorttype":null,"index":"birthday"},{"label":"Contact Type","name":"contact_type_id","sorttype":"integer","align":"right","index":"contact_type_id"},{"formatoptions":{"srcformat":"UniversalSortableDateTime","newformat":"FullDateTime"},"label":"Created At","name":"created_at","formatter":"date","sorttype":"date","index":"created_at"},{"formatoptions":{"srcformat":"UniversalSortableDateTime","newformat":"FullDateTime"},"label":"Updated At","name":"updated_at","formatter":"date","sorttype":"date","index":"updated_at"},{"label":"City","name":"city_id","sorttype":"integer","align":"right","index":"city_id"}],"hoverrows":false}) .addClass("fluid") .jqGrid('gridResize', {"minHeight":80,"handles":"s","minWidth":150}); grid[0].toggleToolbar(); });</script>


I got the answer, i needed to use <%= raw @grid %> but I have no idea why it's not on the documentation of gridify.

0

精彩评论

暂无评论...
验证码 换一张
取 消