javascript - Manipulation of div ids using Dojo 1.5 -


i took on web based product @ company. developed using older version of dojo running on top of catalyst/template toolkit (so it's being submitted perl on backend). have since taken steps @ least date , went dojo 1.5

specifically problem trying solve has div ids. it's form page @ first has combo box, selection pulldown , textbox. in interest of brevity, i'll condense this..... html looks this....

<div id="actions">       <div id="prelim_actions_1_div">    variable: <input type="text" value=""                  class=lighttext size=50                  id="prelim_actions_xvar_1"                  name="prelim_actions_xvar_1"/>      <a href="javascript:void();" title="delete"        onclick="delete_section('prelim_actions_1_div')">       <img src="http://localhost:3000/static/images/16-square-red-delete.png"/></a>    <a href="javascript:void();" title="insert below"       onclick="add_action_below('prelim_actions', 'prelim_actions_1_div')">      <img src="http://localhost:3000/static/images/16-em-down.png"/></a>    </div> </div> 

the first javascript href allows delete text box (title="delete") , second 1 allows add text box increments div ids. in example above

<div id="actions">  

would nest within it...

<div id="prelim_actions_1_div">  ........  ........ </div> <div id="prelim_actions_2_div"> .... .... </div> 

problem dang delete function in javascript. have found possible, through various combinations of adding , deleting real life user, raise errors in firebug trying register div that's registered, , write multiple div ids of same name.

so question, , i'm not looking type me out solution (but need try , learn this), whether or not there easier way of accomplishing this. ability dynamically add , delete text boxes , sure each 1 has unique div id (and name) before submit button hit.

any dojo/javascript pros out there have words of wisdom or links may point me in right direction? janie

a lot depends on how delete_section , add_action_below work now. suggest make delete_section dumb - blindly delete div passed in. when doing add_action_below function this:

//figure out next available spot var = 1; while(dojo.query('#prelim_actions_'+i).length){   i++; }  console.log('available id: prelim_actions_'+i); //create div contents //append after clicked section 

i'm not sure how backend of app works, can go through params , find ones named prelim_actions_xvar_.* , it'll fine.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -