【问题标题】:firing event after the dom has loaded jquerydom加载jquery后触发事件
【发布时间】:2014-02-02 13:05:13
【问题描述】:

我的初始 jquery 运行良好。

jQuery ->
  $(".question_tags").tokenfield typeahead:
    name: 'question_tags'
    valueKey: 'name'
    prefetch: '/admin/question_tags.json'

但问题是当我在 dom 加载后添加新的表单字段时。

除了上述之外,我尝试在单击添加附加字段时附加一个新的令牌字段事件,但它似乎不起作用:

$('form').on 'click', '.add_fields', (event) ->
  $(".question_tags").tokenfield typeahead:
    name: 'question_tags'
    valueKey: 'name'
    prefetch: '/admin/question_tags.json'

有什么想法吗?

【问题讨论】:

    标签: javascript jquery dom bootstrap-typeahead jquery-tokeninput


    【解决方案1】:

    试试下面的代码

    $("document").on ('click', 'form.add_fields', your-code);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-02
      • 1970-01-01
      相关资源
      最近更新 更多