How to make Twitter Bootstrap Collapse work on dynamically loaded html using ajax

后端 未结 3 1645
一向
一向 2021-02-14 12:32

I am loading html using ajax call, this html has Bootstrap Collapse. The issue is Collapse is not working, if you click it wil

3条回答
  •  不要未来只要你来
    2021-02-14 12:46

    My solve is:

        $('.collapse').on('show', function () {
        var $this = $(this);
        if($this.attr('data-href'))
        {
            $this.html($.getJSON($this.attr('data-href'),function(data){
                $this.html(data.html);
                $this.removeAttr('style');
            }));
        }
        })
    

提交回复
热议问题