简体   繁体   English

dom加载jquery后触发事件

[英]firing event after the dom has loaded jquery

I have my initial jquery which works fine. 我有我的初始jQuery,它工作正常。

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

But the problem is when I'm adding new form fields after the dom has loaded. 但是问题是当dom加载后我要添加新的表单字段时。

In addition to the above, I tried to attach a new token field event to the click when it adds the additional fields but it doesn't seem to work: 除了上述内容之外,当尝试添加其他字段时,我尝试将新的令牌字段事件附加到点击,但似乎无法正常工作:

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

Any ideas? 有任何想法吗?

试试下面的代码

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM