I'm having trouble updating elements from JavaScript. My project is fairly complex but here's a tiny piece of it:
myWebService(/*...*/)
.done(function (result) {
var newRows = $(rows).clone();
$('#drop-placeholder').after(newRows);
$(newRows).data('test', 'ZZZZZZZZZZZZZZZZZZZZZZZ');
}
Using Chrome, I can watch these statements execute. However, with newRows in the watch window, I can see that the attribute never gets added/updated. And, sure enough, after the call is done, I don't see the specified attribute on my page.
Can anyone see what I might be missing. rows (and therefore newRows) represents any number of table row elements.
newRowsis already a jQuery object. You don't have to pass it to jQuery again. What do yo mean by "I don't see the specified attribute on my page"? How are you trying to "see" it?newRows.data()? I thought$()gave me additional options. (I was trying to see it by examining the elements in Chrome.).clonereturns a jQuery object, as does$(). If you already have a jQuery object, you don't have to pass it to$()again (the same might be forrows, but I don't know what it is). You usually do$('div')instead of$($('div'))right? :)