Dialog open回调函数只执行一次

时间:2012-12-11 12:54:55

标签: jquery jquery-plugins jquery-ui-dialog

我的jQueryUI对话框打开回调函数仅在对话框第一次打开时执行,但我希望每次打开对话框时它都能正常工作。有人可以帮忙吗?

$('<div><b><center>'+ text +'</center></b></div>').dialog({
    title: '<b>User(s) with a similar name</b>', 
    modal: true,
    autoOpen: true,
    height: 'auto', 
    width: 400,
    resizable: false,
    open: function() { 
        $('#smartpaginate').smartpaginator({ 
            totalrecords: 3,
            recordsperpage: 2, 
            datacontainer: 'all-tabs', 
            dataelement: 'table',
            theme: 'green' 
        });
    },
    buttons: {
        "Close": function() {
            //alert($(this).attr('class'));
            $(this).dialog('close');
            return false;
        }
    }
});

回调中的代码执行分页插件Jquery smart paginator

1 个答案:

答案 0 :(得分:1)

如上所述,此代码段不足以理解您的问题。请参阅this fiddle,始终调用开放回调函数。 我刚刚添加了一个smartpaginate div和一个按钮来控制对话框打开:

<button id="opener">open the dialog</button>
<div id="dialog" title="Dialog Title"><div id="smartpaginate"></div></div>

并显示一条消息,显示调用已执行:

$('#opener').after('<p>dialog open function triggered</p>');

也许你应该看看你的js控制台,并给我们更多的背景。

相关问题