jQuery Listbox load items

Hello,

I was wondering if there is a way of pre-loading a Jquery list box with items (similar to .items property in design mode) through code rather than using (.additem) as it is very slow ( i am loading about 1000 items at once), any ideas?

Warm Regards,

My first question is: 1000 items? It can’t be easy for the user to scroll through that many to find an item.

Second question: Which control do you actually mean?
jqWidgets Listbox or jQuery Mobile List?

and an idea: the reason it takes a long time is that it needs to refresh the control after each item is added. Is it faster if you hide the control while doing this?

Hello and thanks for the reply.

The reason i am adding 1000 items is beacuse i’ve created a kind of a dictionary and i use the filter option to go through the list (which is very effiecient by the way).

I am using jQuery Mobile List.

I will definately try to hide the controller.

Warm Regards,

Hello,

I’ve tried to hide the List while adding the items, same problem…

You will need to dive into HTML to do this. If you have a jQM List control named List1, type List1.innerHTML into the Chrome Console. You’ll get something like this:

<ul id="List1_list" data-role="listview" class="ui-listview ui-listview-inset ui-shadow" data-corners="false" data-icon="arrow-r" data-inset="true" data-divider-theme="b" nsb-imagestyle="none">
  <li class="ui-first-child"><a id="List1_0" nsbclick="List1" nsbvalue="0" href="#" style="white-space:normal;" class="ui-btn ui-btn-icon-right ui-icon-arrow-r">One</a></li>
  <li><a id="List1_1" nsbclick="List1" nsbvalue="1" href="#" style="white-space:normal;" class="ui-btn ui-btn-icon-right ui-icon-arrow-r">Two</a></li>
  <li class="ui-last-child"><a id="List1_2" nsbclick="List1" nsbvalue="2" href="#" style="white-space:normal;" class="ui-btn ui-btn-icon-right ui-icon-arrow-r">Three</a></li>
</ul>

You will need to construct a string with a similar format, with all 1000 items, then assign it to List1.innerHTML.

Hello,

Thanks for the reply.

I thought about that but didn’t know how, is it possbile to modify this in runtime?
How can i access the html via code (basic)?

Warm Regards,

Abdalla

Hello,

i am trying to, how do i overcome the " character?

can You please show me an example?

Thanks

You can use a single quote in place of the double quote.

List1.innerHTML = myNewHTML