RadComboBox: click handlers lost after scrolling when using a client item template with load on demand

2 posts, 0 answers
  1. Aleksey
    Aleksey avatar
    2 posts
    Member since:
    Aug 2015

    Posted 04 Apr 2017 Link to this post

    I'm using a RadComboBox in the load on demand (lazy) mode with a web service.

    I'm using a client side item template of this form: <input type='checkbox' id='cb_#= Value #'/><span>#= Text #</span> (adding a checkbox before each item's text)

    In the itemDataBound client side handler for this RadComboBox I'm retrieving the particular item's DOM element and the nested checkbox'es DOM element and adding a click handler function for each of them (using jquery's $(element).click(function() {})).


    The click handler functions work fine until I scroll the items out of view and then scroll back, after that the click handlers are not called anymore.


    I suppose this is because the DOM elements representing the items get re-created as they are scrolled in and out of view. But the itemDataBound event is raised only once and is not raised again when an item is scrolled back in view.

    The only workaround I can think of is to use the onclick attribute in the HTML and reference a global function from there, but this is ugly.

    Is there a nicer solution for this then using the onclick attribute?









  2. Aleksey
    Aleksey avatar
    2 posts
    Member since:
    Aug 2015

    Posted 05 Apr 2017 in reply to Aleksey Link to this post

    What it does actually it appends to innerHtml of the list element, but this is effectively re-moving and re-adding every node under the list element.

    I worked around this by assigning my click hander and doing the databiding in the itemsRequested client side handler, iterating over the entire list of items obtained with the get_items() method of the RadCombobBox client side object.

    itemsRequested is called every time after new items are added to the list and therefore every time after the DOM is re-created.



Back to Top