jqModal,jquery问题

发布于 2024-07-21 06:22:09 字数 697 浏览 19 评论 0原文

我有以下代码;

// 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尾戒 2024-07-28 06:22:09

你的问题是当JS引擎设置onHide的值时执行f。 您真正想要的是将 onHide 设置为内联定义的匿名函数,该函数调用 load_it:

onHide:function(hash){load_it($(this).attr('id'));}

您实际上不需要那里的 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:

onHide:function(hash){load_it($(this).attr('id'));}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文