This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes About refreshing div in JQuery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "About refreshing div in JQuery" Watch "About refreshing div in JQuery" New topic

About refreshing div in JQuery

Suvojit Chakraborty
Ranch Hand

Joined: Nov 10, 2009
Posts: 62

I have a requirement of refreshing a div in jquery. The scenario is:
I have following structure in html/jsp:

Now my requirement is to make all the inputs inside the provider-d1 divs required (by puting an asterix after the label), as soon as user input some text in the text box.

following is the jquery code I am using to do this:

I am calling above code on doc.ready(). Now this works perfectly fine in case , provider-d1 div is already present. But there is also a button which clones above div and update the id.
Example: provider-d1 becomes provider-d2 and similarly input elements inside also get incremented.
So if I add another div, the logic in script doesnt get applied because var providers = $('#provider div[id^="provider-d"]'); would return only div which are present during the time pages was loaded. Div generated afterward doesnt get picked.

Please guide me to find a solution so that I may refresh my main div(provider) prior to the var providers = $('#provider div[id^="provider-d"]'); , so that newly added divs also get included in result.

Thanks for help

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

What calls your function requiredProvider() ?

GenRocket - Experts at Building Test Data
Suvojit Chakraborty
Ranch Hand

Joined: Nov 10, 2009
Posts: 62

Thanks for reply.

requiredProvider() is called from inside $(document).ready(function(){ requiredProvider(); }) which I have placed in <script> section of a xsl file which renders xml and generate view.

My problem perhaps will be solved if somehow I can call this from $(document).update()/reload() sort of function. I am not aware of existence of any such function but I am guessing some function to satisfy my need exist.

Thanks for help
I agree. Here's the link:
subject: About refreshing div in JQuery
Similar Threads
Retrieve data from other server using JavaScript
calling the struts action on jquery button click
jQuery not working on page
How to getParameter value
Doubts in jsp