Grails的链接下拉链接、Grails

2023-09-10 21:26:51 作者:琴键上的泪

我想实现链接的下拉使用教程的这里。我的班是不是直线前进的那些教程虽然。

我想链下拉框中的 create.gsp 视图中的加载类。每个负载属于从帐户类的帐户,每个帐户属于从用户类的用户,每个用户都有几个货运目的地地址类。

我的目标是在此基础上考虑选择具有货物的目的地场了日期。

我无法理解在教程中的AJAX功能(步骤3),以及它与Grails的功能(步骤4)。

下面是AJAX code:

 函数respondToSelect(事件)
 {
       新的Ajax.Updater(memberSelect
          / chainedSelect /家庭/ updateSelect
          {方法:'得到',参数:{了selectedValue:$ F(familySelect)}}
         );
 }
 

下面是Grails的方法:

 高清updateSelect = {

     高清familySelected = Family.find(来自家庭的家庭中,family.surname =:姓,[姓:params.selectedValue])

渲染(模板:selectMember,型号:['familySelected':familySelected])

}
 
在 Grails 中使用 jQuery 和 DataTables Linux 中国

如果有人可以只解释一下什么是AJAX功能的第三个参数是做我想我可以计算Grails的一部分了。

{方法:'得到',参数:{了selectedValue:$ F(帐户)}}

解决方案   

如果有人可以只解释了AJAX什么样的第三个参数   功能是做

第三个参数是参数的对象获得通过,以告诉它如何使HTTP请求到服务器的更新。

请请求的HTTP GET请求:

 方法:'得到'
 

将以下命名的查询参数:

  {了selectedValue:$ F(帐户)}
 

$ F 是一个原型快捷方式的检索元素的值。在这种情况下,它得到的DOM元素的id为选定值帐户

这最终导致类似如下要求:

  GET / chainedSelect /家庭/ updateSelect?了selectedValue = someValue中
 

在哪里someValue中是在帐户选择列表中的当前选择的项目。

I'm trying to implement chained drop down boxes using the tutorial here. My classes are not as straight forward as the ones in the tutorial though.

I want to chain the drop down boxes for the create.gsp view in the Load class. Each load belongs to an account from the Account class, and each account belongs to a user from the User class, and each user has several cargo destinations from the Address class.

My goal is to have the cargo destination field up date based on which account is selected.

I am having trouble understanding the AJAX function in the tutorial (step 3), and how it relates to the Grails function (step 4).

Here is the AJAX code:

     function respondToSelect(event)
 {
       new Ajax.Updater("memberSelect",
          "/chainedSelect/family/updateSelect",
          {method:'get', parameters: {selectedValue : $F("familySelect")} }
         );
 }

Here is the Grails method:

    def updateSelect = {

     def familySelected = Family.find("from Family as family where family.surname=:surname", [surname:params.selectedValue])

render (template:"selectMember", model : ['familySelected' : familySelected])

}

If someone could just explain what the third parameter of the AJAX function is doing I think I can figure the Grails part out.

{method:'get', parameters: {selectedValue : $F("account")}}

解决方案

If someone could just explain what the third parameter of the AJAX function is doing

The third argument is an object of parameters that get passed to the Updater that tell it how to make the HTTP request to the server.

Make the request an HTTP GET request:

method:'get'

Pass the following named query parameters:

{selectedValue: $F("account")}

$F is a prototype shortcut to retrieve the value of an element. In this case, it's getting the selected value of the DOM element with id account.

This ultimately results in something like the following request:

GET /chainedSelect/family/updateSelect?selectedValue=someValue

Where "someValue" is the currently-selected item in the "account" select list.