English 中文(简体)
如何结束 j锁链,然后履行你的职责,但所有职能都在链条内。
原标题:How would you end the chain in jquery, then execute your function, but all while inside a chain function

我知道这是一个不容置疑的问题,因此我基本上说以下几点。 我有:

$("#dialog-areyousuremodal").dialog({
    resizable: false,
    height: 120,
    modal: true,
    buttons: {
        "Yes": function() {
            $(this).dialog("close");
            // more stuff coming soon
            },
        "No": function() {
            $(this).dialog("close");
        }
    }
}).end().centerFixed();

<div class="hidden" id="dialog-areyousuremodal" title="Delete Confirmation">
    <p>Are you sure you want to delete this row?</p>
</div>

我建立了一种习俗功能,这种功能延伸到:

(function($){
    $.fn.extend({
        centerFixed: function () {
            return this.each(function() {
            $(this).end();
            $(this).css({position:"fixed"});
            $(this).css("top", (($(window).height() - $(this).outerHeight()) / 2) + "px");
            $(this).css("left", (($(window).width() - $(this).outerWidth()) / 2) + "px");
            });
        }
    });
})(jQuery);

我的目标是取代(......)。 你可以看到,我试图将......end()放在习俗职能中,但这不是工作。 I m试图避免在方言或心脏(Fixed)一行的尾声上加起来。

对这一问题有何想法?

最佳回答

当<代码>centerFixed(>>时,你根本不能说它没有它所呼吁的职能链条的概念。 它知道的是this,这是从前链条方法中要求的功能中回收的任何物体。

由于您在请打电话到dialog()后重新链条,请在centerFixed内 变量this无论出于何种目的,都将是dialog(<>>/code>(我认为是ID dialog 标的)。

如果你想要确保你的代码在设立方言时才能运行,那么最好采用以下方式:create event

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...