RE: feeling stupid....
"Lon Boonen" <[email protected]>
| Newsgroups | gmane.comp.web.dom.wdf |
|---|---|
| Message-ID | <[email protected]> |
Better yet, of course, is not to attach an event handler for each and every row... why would you? who's going to delete all rows by hand? why not attach one event handler a bit up the tree? and make that handler figure out what row to delete. The moment you're attaching tens of event handlers is the moment you should realize you're doing something wrong. ------------------------------------------------- Q42: http://www.q42.nl Xopus: http://xopus.com > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Seb Frost > Sent: dinsdag 3 januari 2006 13:26 > To: [email protected] > Subject: RE: [wdf-dom] feeling stupid.... > > > ok, but this is executed every time the user adds a new row > into a table, of > which there could theoretically be thousands - so i can't > hardcode all of > those numbers in like you just have can I? > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]]On Behalf > Of Lon Boonen > Sent: 03 January 2006 12:25 > To: [email protected] > Subject: RE: [wdf-dom] feeling stupid.... > > > put it in some method where num is not changed... > > attachClickHandler(el1, 1}; > attachClickHandler(el2, 2}; > attachClickHandler(el3, 3}; > > function attachClickHandler(el, num) > { > el.onclick = function() {deleteRow(this,num);return false;}; > } > > > > > ------------------------------------------------- > Q42: http://www.q42.nl > Xopus: http://xopus.com > > > > > > -----Original Message----- > > From: [email protected] > > [mailto:[email protected]] On Behalf Of Seb Frost > > Sent: dinsdag 3 januari 2006 12:47 > > To: [email protected] > > Subject: [wdf-dom] feeling stupid.... > > > > > > num =1; > > el1.onclick = function() {deleteRow(this,num);return false;}; > > num++; > > el2.onclick = function() {deleteRow(this,num);return false;}; > > num++; > > el3.onclick = function() {deleteRow(this,num);return false;}; > > > > > > I know this example seems weird and you'll ask why I don't > > just hardcode the > > number in, but this is just me giving the most clear example > > of the problem > > without you having to trawl through the rest of my code! > > > > The problem, as I'm sure you can guess, is that whichever > > element the user > > clicks on (thus invoking "deleteRow"), num is seen as being 3. > > > > What I want is for it to be 1 on the first row, 2 on the > > second, and 3 on > > the third. > > > > How can I pass in the "current" value of num and stop it from > > using the > > "live" value? I thought an eval would do it at first, but > > soon realised my > > mistake and now am not sure how else to do it? > > > > > > I'd like a solution rather than a workaround to avoid the > > issue (I can see > > several of those) because I'm sure there must be a way to do this! > > > > Cheers > > > > > > > > Unsubscribe > > [email protected] > > > > List info > > http://www.quirksmode.org/dom/list.html > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > Unsubscribe > [email protected] > > List info > http://www.quirksmode.org/dom/list.html > Yahoo! Groups Links > > > > > > > > > Unsubscribe > [email protected] > > List info > http://www.quirksmode.org/dom/list.html > Yahoo! Groups Links > > > > > > > Unsubscribe [email protected] List info http://www.quirksmode.org/dom/list.html Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/wdf-dom/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/