multiselect icon indicating copy to clipboard operation
multiselect copied to clipboard

Is there a way to dynamically add items after the multiselect has initialized?

Open kramerica opened this issue 15 years ago • 4 comments

For example, I have a modal window with a select list inside of it. I'm using C# and the list gets populated with options from a callback response inside of a jquery click event. After the list is populated I have the modal actually display with the list of items. The problem is that $(#id).multiselect() must be called before the click event, and cannot be called inside of it (the multiselect plugin has no width and is scrunched up to the left of the modal window if I do call it inside of the click event).

Since the original select list gets populated after the multiselect is called, nothing gets added to the multiselect list. So is there anyway I can add select options to the multiselect after all of that, or is there some way around this?

Thanks

kramerica avatar Jan 15 '10 14:01 kramerica

Hi Kramerica: Have you found a way to accomplish the task in your comment above?

I found another multiselect jquery plugin with a refresh method but I would like to use this one.

Regards:

Paul

pauldj54 avatar Apr 03 '11 15:04 pauldj54

Have you had any success dealing with this issue?

bbuchalter avatar Apr 19 '11 19:04 bbuchalter

I had to leave it at this moment because a have a deadline with the customer, I use another control (not a jquery widget), I will return to this issue in a few weeks, but first I'll study a little bit about jquery widget development

pauldj54 avatar Apr 20 '11 09:04 pauldj54

I was able to add items to the select using the following script:

However, I ended up using nested form attributes to add new records in the system more easily. See https://github.com/bbuchalter/complex-form-examples/tree/unobtrusive-jquery-deep-rails3

bbuchalter avatar Apr 20 '11 11:04 bbuchalter