$(文档).foundation ();不工作

$(document).foundation(); not working

本文关键字:工作 foundation 文档      更新时间:2023-09-26

我试图得到我的元素,我通过ajax加载回工作,但当我试图重新初始化事件对他们,它根本不起作用。我试图在不同的地方插入$(document).foundation();在我的代码,但没有:(

下面是一个例子:

    $.ajax({
        url: 'dashboard/ajax/links/get',
        method: 'post',
        data: {
            _token: $('input[name=_token]').val()
        },
        success: function(data) {
            $('.links-container').html(data);
            $(document).foundation();
        }
    });

任何想法?

另一个例子
// open edit link modal
$('.item-link-edit').on('click',function(e){
    e.preventDefault();
    // get item id
    var id = getItemId(this);
    // open modal and load content
    $('#edit-link-modal').foundation('reveal','open',{
        url: 'dashboard/ajax/links/modals/edit',
        data: {
            id: id
        },
        success: function() {
            setTimeout(function(){
                $(document).foundation();
                console.log('reinit');
            },1000);
        }
    });
}); 

仍然不能工作:/

如果向DOM添加新内容,则需要使用reflow

$(document).foundation('reflow');

Reflow将使Foundation检查DOM中的任何元素,并对它们重新应用任何侦听器。如果你不想流遍所有内容,你可以指定你想重新应用的模块;

$(document).foundation('orbit', 'reflow'); // orbit, for an example

可以在这里找到更多的文档:http://foundation.zurb.com/docs/javascript.html