1

I have a form where I want to make all new DOM elements of the "editbuttons" class into buttons immediately with Jquery UI. New objects of the "editbuttons" class are generated on the page from multiple different jquery functions. Would I have to call .button() inside each of these functions or is there an easy way so that as soon as a new instance of this class is added to the page, it is made into a button?

$('.editbuttons').button();
user1000219
  • 115
  • 1
  • 2
  • 6

2 Answers2

0

yes use

 $('. editbuttons').livequery().button();

take a look at this post very similar case

Community
  • 1
  • 1
mcgrailm
  • 17,469
  • 22
  • 83
  • 129
0

jQuery live() can be used to attach a handler with a given element, but unfortunately it does not support "create" event. You may use The only option you have is to use the liveQuery plugin which scans the dom every x milliseconds looking for selector matches. When a new element is found it will run a function. For e.g.

$('.editbuttons').livequery().button();

Well, I personally dont like the overhead of this but it may give you the desired functionality.

Viral Patel
  • 8,506
  • 3
  • 32
  • 29