I have the following javascript that is being called in the OnClientReordered event. I am trying to change the text of the items in the list when they are reordered. What I am seeing is the item does not update the first time the event fires. The second time the event fires the text gets rendered correctly. (The text is being changed properly, as I can put a watch on the values, and the text is correct. It is just not being rendered) Is there something I am doing incorrectly here? I could find no information from the documentation on the API.
function SetcontentorderNumber() { |
reg = new RegExp("\\[\\d*\\]") |
var list = $find("<%= foo.ClientID %>"); |
var length = list.get_items().get_count(); |
list.trackChanges(); |
for (var i = 0; i < length; i++) { |
var text = list.getItem(i).get_text(); |
if (reg.test(text)) { |
texttext = text.replace(reg, "[" + (i + 1) + "] "); |
list.getItem(i).set_text(text); |
} |
else { |
text = "[" + (i + 1) + "] " + text; |
list.getItem(i).set_text(text); |
} |
} |
list.commitChanges(); |
} |