English 中文(简体)
动态发展 j 铁路运输工具3
原标题:Dynamically Generating jQuery script in Rails 3 application

我在申请时采用了j Query 写法。 我愿以动态方式生成微粒参数。 例如,人控制器的贴现价值需要在控制器的参数基础上产生。 问题在于该书的运用。 js是静态的,不能确定如何使守则的一个部分具有活力,即接受控制人的参数。 请允许我知道,是否有想法,我非常赞赏。

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
});
最佳回答

部分称为“变数”。 haml:

:javascript
  var user =  #{current_user.email} ;
  var paactions_url =  #{@paactions_url} ;

阁下:

@paactions_url = paactions_url

您认为:

= render :partial => "variables"

在您的书中:

jQuery("#paactions").jqGrid({
    url: paactions_url,
    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
});

或者将ham子转向er子,或您所用的任何排他性语言。 我也就你在座的 j子提出名字,但我不知道你的 j。

问题回答

Add a meta tag to your layout which can contain the URL, the grab this as part of your script.

In the layout:

<meta name="person-url" content="/people/<%= @person.id %>/pa.json"/>

当然,如果存在适当的变量,你就只需要这样做。

在您的联合文件中:

url: $("meta[name=person-url]").attr( content )

如果我希望我的联合材料尽可能不妥协,那么这种技术就非常有用。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签