error removing, then adding then removing items

1 posts, 0 answers
  1. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 12 Jul 2013 Link to this post

    SOLVED:


    I am get the following error:

    1. Uncaught TypeError: Cannot call method 'get_selected' of undefined Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&comp…e21a%3a650fdad%3aa960fda2%3aca44ff11%3a29e4ab07%3a59462f1%3aa51ee93e:27811
      1. b

    I am removing all of the items of a listbox and then adding new items.  It works the first time but when i call the JavaScript function the second time I get an error.


    //rangeitems looks like: "25|1.25,50|1.00,100|.85,125|.70"
    var
    items = listbox.get_items();
            items.forEach(function (item) {
                items.remove(item);
                listbox.trackChanges();
                listbox.get_items().remove(item);
                listbox.commitChanges();
            });
     
            for (i = 0; i < rangeitems.length; i++) {
                var items = rangeitems[i].split("|");
                var item = new Telerik.Web.UI.RadListBoxItem();
                item.set_text(items[1]);
                item.set_value(items[0]);
                listbox.trackChanges();
                listbox.get_items().add(item);
                listbox.commitChanges();
            }

    I have a drop down that is loading the array as an attribute and I call this function using  onSelectedIndexChanged.

    Any ideas?

    Marty

    Not sure what part fixed this issue but here is the new code if anyone has the same issue.

    var items = listbox.get_items();
            items.clear();
            items.forEach(function (item) {
                items.remove(item);
                listbox.trackChanges();
                listbox.get_items().remove(item);
                listbox.commitChanges();
            });
            for (i = 0; i < rangeitems.length; i++) {
                listbox.trackChanges();
                var items = rangeitems[i].split("|");
                var item = new Telerik.Web.UI.RadListBoxItem();
                item.set_text(items[1]);
                item.set_value(items[0]);
                listbox.trackChanges();
                listbox.get_items().add(item);
                listbox.commitChanges();
            }



Back to Top