This is a migrated thread and some comments may be shown as answers.

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

1 Answer 84 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Aleksey
Top achievements
Rank 1
Aleksey asked on 04 Apr 2017, 06:27 PM

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?

 

Thanks,

Aleksey

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Aleksey
Top achievements
Rank 1
answered on 05 Apr 2017, 12:14 PM

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.

 

 

Tags
ComboBox
Asked by
Aleksey
Top achievements
Rank 1
Answers by
Aleksey
Top achievements
Rank 1
Share this question
or