jqModal,jquery问题
我有以下代码;
// open the modal when an element with a class 'edit' is clicked
$('.edit').live('click', function() {`
$('#mdl_edit').jqm({onHide: f($(this).attr('id')), ajax: 'ajax/edit_modal.aspx?lid=' + $(this).attr('id'), ajaxText: '<img src="img/ajax-loader.gif"' });
$('#mdl_edit').jqmShow();
return false;
});
var f = function load_it(lID) { load_single_record(lID); };
问题是,当我单击带有“edit”类的元素时,函数 load_it 甚至在对 edit_modal.aspx 的 ajax 调用之前运行。实际上,我要求它在模态框关闭后运行。 另外,我需要将 $(this).attr('id') 传递给模式关闭后需要运行的函数。我做错了(我知道),但有人可以告诉我正确的方法吗模式关闭后,通过向其传递变量来调用函数的方式?
问候,
凯姆
I have the following code;
// open the modal when an element with a class 'edit' is clicked
$('.edit').live('click', function() {`
$('#mdl_edit').jqm({onHide: f($(this).attr('id')), ajax: 'ajax/edit_modal.aspx?lid=' + $(this).attr('id'), ajaxText: '<img src="img/ajax-loader.gif"' });
$('#mdl_edit').jqmShow();
return false;
});
var f = function load_it(lID) { load_single_record(lID); };
the thing is, when ever I click on an element with a class "edit" the function load_it runs before even the ajax call to the edit_modal.aspx.. I actually require it to run after the modal box is closed. Also, I need to pass the $(this).attr('id') to the function that needs to be run after the modal is closed.. I am doing it wrong (I know it) but can someone show me the correct way of calling a function, by also passing a variable to it, after the modal is closed?
regards,
kem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题是当JS引擎设置onHide的值时执行
f
。 您真正想要的是将 onHide 设置为内联定义的匿名函数,该函数调用 load_it:您实际上不需要那里的
hash
,因为您没有使用它,但是(根据jqModal 的文档)那里可能有一些你感兴趣的东西。your problem is that
f
is executed when the JS engine sets the value of onHide. What you actually want is to have onHide set to an anonymous function, defined inline, that calls load_it:you don't actually need the
hash
there, since you're not using it, but (as per jqModal's documentation) there might be some interesting stuff there for you.