3

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

user006779
  • 1,011
  • 4
  • 15
  • 28

3 Answers3

5

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

Community
  • 1
  • 1
rolling stone
  • 12,668
  • 9
  • 45
  • 63
0

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.

Defrag
  • 146
  • 1
  • 5
0

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
    });
});
Edyn
  • 2,409
  • 2
  • 26
  • 25