weixin_33682790 2015-09-16 11:27 采纳率: 0%
浏览 48

Primefaces的jQuery问题[重复]

This question already has an answer here:
                </div>
            </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/14400624/jsf-primefaces-ajax-updates-breaks-jquery-event-listener-function-bindings" dir="ltr">JSF/PrimeFaces ajax updates breaks jQuery event listener function bindings</a>
                            <span class="question-originals-answer-count">
                                (1 answer)
                            </span>
                    </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2015-09-16 14:20:00Z" class="relativetime">4 years ago</span>.</div>
        </div>
    </aside>

I have a PrimeFaces based Webapp which consists of mulitple Tabs and each Tab contains a datatable. I am using jQuery to bind click handler to input fields having a certain class in a datatable component. Here is the jQuery code:

$(document).ready(function() {
  $('.ui-column-filter').bind('click' , function() {
   //Desired functionality comes here
   });

 };

Now, the issue I am facing is that this code works only the first time the webpage loads and only for the first tab. As soon as I click another tab, the code stops working, even for the first tab for which it was previously working. Each tab fetches its content via AJAX so my guess is that as soon as an AJAX request is made, the event handlers attached via $(document).ready do not function anymore. How can I solve this problem?

</div>
  • 写回答

1条回答 默认 最新

  • weixin_33738578 2015-09-16 11:41
    关注

    Solved the problem via this link JSF/PrimeFaces ajax updates breaks jQuery event listener function bindings as follows :

      $(document).on("click", ".ui-column-filter", function() {
      //The desired functionality
     });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题