开发者

Jquery live() and jquery ui button()

I want to u开发者_StackOverflowse jquery ui button for buttons created in future. can i use live()? what is eventType in live()?


You can download the .livequery() plugin, which should give you the same functionality:

$(".button").livequery(function() {
  $(this).button();
});

.livequery() plugin: http://plugins.jquery.com/project/livequery

As far as I know there is no way to use live with the JQuery UI button. This SO question might also be helpful: Adding jQueryui Buttons to dynamically added content


There is a way to do this. The jquery ui button call adds "ui-button" as a class to either the element or the element's label (in the case of radio/checkbox). You can grab the elements with the "ui-button" class and do "live" functions against those elements.

So if your html is...

<div id="parent_div">
    <input type="checkbox" id="test_checkbox" />
    <label for="test_checkbox">Test</label>
</div>

then your script would be...

$(function() {
    $("#parent_div .ui-button").live("mouseenter", function (e) {
        // code to show something here
    });
});


I use this solution:

content.load('URL #sectionToLoad', function(event) {
    $("SELECTOR, button").button();
    ...
});

It's work fine

UPDATE

Use delegate to assign Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements. jQuery API: link, instead of live method, and don´t forget to undelegate the event.

Hope this help you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜