Articles in this section
Category / Section

How to rebind new datasource to existing Listbox?

1 min read

By default, while rebinding the datasource to Listbox control, it automatically clears the list item first and then renders the control with the newly updated datasource.

Refer the following code examples to rebind the new datasource.

HTML

<div id="lb" data-role="ejmlistbox" data-ej-databinding="true" data-ej-datasource="window.dbitem1">

</div>

<input id="button" type="button" data-role="ejmbutton" data-ej-text="Clear" data-ej-touchend="touchEnd" />

Script

<script>

    window.dbitem1 = [

        { "text": "Hot Singles" },

        { "text": "Rising Artists" },

        { "text": "Live Music" },

        { "text": "Best of 2013 So Far" },

        { "text": "Hip-Hop and R&B Sale"}];

    window.dbitem2 = [

        { "text": "Music" },

        { "text": "Videos" },

        { "text": "Chat" },

        { "text": "Others" }];

    function touchEnd() {

        $('#lb').ejmListbox("clear");

        $("#lb").ejmListbox({ dataSource: "window.dbitem2" });

    }

</script>

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied