开发者

Triggering event handler attached to it's own object, but inside a chain?

开发者 https://www.devze.com 2023-01-21 06:39 出处:网络
Right now I have: $(\"#myElement\").bind(\"buildTimelin开发者_如何学Pythone\", function (event, newViewObj) {

Right now I have:

$("#myElement").bind("buildTimelin开发者_如何学Pythone", function (event, newViewObj) {
    curDomObj = $(this).children(".timeline"); //this refers to #myElement

    curDomObj.draggable({
        axis:"x",
        drag:curDomObj.trigger("drag")
    });
});

I'd much rather just have one chain, but is there a way to refer to the current element at your position in the chain?:

$(this).children(".timeline").draggable({
    axis:"x",
    drag:$(this).trigger("drag") //this still refers to #myElement, but I want
                                 //it to refer to #myElement .timeline
});


What about:

$("#myElement").bind("buildTimeline", function (event, newViewObj) {
    $(this).children(".timeline").draggable({
        axis:"x",
        drag:$(this).children(".timeline").trigger("drag")
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消