Reputation: 303
I have a div whose content is rendered during runtime (rendered attribute is set false), after a click on a button.
What I'm trying to do is use javascript (with jquery) to manipulate the content of the div. I'm currently working with timeout, but this is unsuitable due to fluctuating loading times.
Is there any way to make javascript notice and execute the function as soon as rendered is set true?
EDIT: I think I expressed myself inexpertly:
What I'm doing concretely: I have a button which executes a sql query and displays the results in a table which is surrounded by a div. The div, thus the table, are set as rendered="false" and are rerendered by clicking the button.
The javascript function that I'm trying to invoke is used to style rows of the table. So the js function needs to check for the div, which is not possible before the div is rendered.
Upvotes: 0
Views: 1190
Reputation: 10048
Use oncomplete
on that button to call that javascript styling function.
<p:commandLink oncomplete="jsFunction()" >
Hope this helps.
Upvotes: 1
Reputation: 2733
You can bind the DOMNodeInserted
event, as described here.
That enables you to do something like this:
$(document).bind('DOMNodeInserted', function(event) {
var element = $(event.target);
if (element.hasClass("myDiv")) {
$(element).text("changed Content");
}
});
Upvotes: 0