【问题标题】:cloning a select list which is dynamically created克隆一个动态创建的选择列表
【发布时间】:2012-03-26 17:51:32
【问题描述】:

我的要求是克隆选择框(其中选项是动态填充的)。 我正在尝试在 - jquery remove/add select options after cloning select list

我的视图代码是-

<tr> <td>Reference Table:</td>
<td><g:select name="tableCombo"
            noSelection="${['':message(code:'Select Table')]}"
            from="${result}" value="${tableName }" onchange="${remoteFunction(action:'getColumns', update:'columns', params:'\'tableCombo=\' + this.value')}"/> </td></tr>
<tr id ="cons"><td nowrap>Constraint On:</td>
        <td nowrap><g:select name="columns" from="[]" /></td>
        <td nowrap>Constraint Value:</td>
        <td nowrap><g:textField name="columnValue" value="${enterVal }" />                  
<a id="clone" >Clone</a>  ///how to call clone 

我是 jquery 的新手,所以请建议如何去做。 想要在点击时克隆 cons。

谢谢。

【问题讨论】:

  • 你能不能解决你的问题,很难理解你面临什么问题

标签: jquery grails clone gsp


【解决方案1】:

这个:?

$('#clone').click(function() {
   var consClone = $('#cons').clone();

   // now depends where you would like to put the copy 
   // of consClone to, for example, to the same table as the original #cons was:
   $('#cons').parent().append(consClone);   
});

请注意,最好在整个文档中使用一个 id,一种快速的方法是使用 class 而不是 id 来表示缺点

【讨论】:

  • 感谢安德烈亚斯。我还需要在页面上回发这些克隆的选择框,并在所有选择中使用选定的选项。是否可以使用克隆或者我应该创建选择并仅复制选项?
  • 不太清楚你的意思..对不起。你能详细说明一下吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-01
  • 1970-01-01
  • 2011-08-11
  • 2017-07-29
  • 1970-01-01
  • 2013-01-06
  • 1970-01-01
相关资源
最近更新 更多