Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

About refreshing div in JQuery

 
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

Suvojit
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What calls your function requiredProvider() ?
 
Suvojit Chakraborty
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

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
Suvojit
 
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic