Git Product home page Git Product logo

multiselect's Introduction

jQuery UI Multiselect

This repository is no longer actively maintained by the author. However, pull requests are always welcome. If there's someone interested in officially maintaining the plugin, please let me know.

In case you are looking for an AJAX version, please also consider "Yanick Rochon's":http://github.com/michael/multiselect/tree/next version, or also check the official "version 2.0":https://github.com/yanickrochon/jquery.uix.multiselect currently in development.

To get the order of the selected items as selected, you can do like

var form = $("form#my_form");
$(form).on('submit', function(){
	$("ul.selected li").each(function(){
		var selected_value = $(this).attr('data-selected-value');
		if(selected_value){
			$(form).append("<input type='hidden' value='" + selected_value + "' name='selected_items_values_in_order[]' />");
		}
	});
});

multiselect's People

Contributors

boxmo avatar cburgdorf avatar hazzik avatar hoopla avatar jgarber avatar koichirose avatar ksn135 avatar michael avatar pneff avatar ssi-anik avatar takuji avatar trekdemo avatar viart avatar yanickrochon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multiselect's Issues

Sort order when use plus button

With bellow operation...

  1. "Option Sortable" is enable.
  2. Select items with plus button. ( for example, original list ordered 1, 2, 3. Then click order 3, 2, 1).
  3. Post or put these data (by http).

In this case, we expect sent list ordered by selected list order. But, it send with "original list order". Then, I insert some code write bellow.

73a160,168

      if (this.options.sortable) {
          that = this;
          // apply the new sort order to the original selectbox
          that.selectedList.find('li').each(function() {
              if ($(this).data('optionLink'))
                  $(this).data('optionLink').remove().appendTo(that.element);
          });
      }

Thanks.

Index not updated on click event

I'm running into a minor issue with sorting. Basically it seems like the sort does not apply when clicking the '+' icon to add items to the selectedList. Here are the steps to reproduce the issue I'm having:

Let's say I have an availableList with the following items (in this order):

  • A
  • B
  • C

Now I'll go ahead and add the following items to the selectedList (in this order) by clicking the '+' icon next to each item:

  • C
  • A

The index on the original does not appear to update, so the items are submitted in their original order, which is: A C This issue doesn't seem to occur when I do the same thing using the drag and drop functionality of the application. I'm guessing there may be a issue in the click event that is not updating the index. Anyways not sure if this is expected behavior or not, but any insight on how this could be resolved would be great. Also please let me know if any additional information is needed, thanks!

Populating list stops unexpected

Function _addNode looks for successor. When it is found line: node.insertBefore(succ) is called but it doesn't insert any node.

When succ is null then everything works fine.

Available List Item Disappears

An available list item disappears when dragging and releasing in the available list.

I meant to mention this is only on the next branch. I was using next version as the main version is too slow for 250 items.

dividerLocation param is undefined

Not sure why this is happening, but the default dividerLocation isn't being used, however when specified in the instantiating parameters it works perfectly

Line: 877, 250

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

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

Initial sorting of selected items

It would be good to be able to order the initially loaded selected items as they are ordered in the html rather than by alphabetical order.

Slow with large lists

Hi,
The function is great, looks professional and ease of use.
Problem is I can see that it takes up a very long time to generate the mark with list over 500+ items.
Is it possible that I can produce the html mark up for the html page in advance and the multiselect function doesn't need to produce the it, but the javascript functions still work.
My idea would be to use PHP script to create the markup list to save the javascript from doing it.
Cheers
Kaz

Items removed from list incorrectly appear in filtered master list

When an item is removed from the selected list, it'll reappear in the master list (good) but even when the master list is filtered (bad). For example, if the master list is filtered for "can", I'll see Canada and Vatican City, but if I remove Albania from the selected list, it'll pop into the master list, even if it matches the filter.

Remote lookup does not work in Chrome

The remote lookup does not work in Chrome (currently viewing using Chromium 5.0.375.125). The following error appears to occur on ui.multiselect.js:50:

Uncaught TypeError: Cannot call method 'split' of undefined

I created a sample remote page that would return a few elements. Then in the debugger I placed a break at line 50:

lines
Array
0: a=Apple
1: b=Banana
2: c=Cat
constructor: function Array()
index: undefined
input: undefined
length: 3
proto: Array

On each iteration of the loop I see the following:

i=0
i=1
i=2
i=index

However, this loops stops at i=2 in Firefox so there are no issues with this. Changing line 49 from:

for (var i in lines) {

to

for (var i=0; i < lines.length; i++) {

seems to resolve this issue.

Add remove all with multiple instances on same page

I'm using multiple instances of this great widget on the same page (downloaded the fix for multiple instances referred to from issues section.).

This works fine when adding single entries, but when I click "add/remove all" everything is moved in all of the widgets, not just the one where the button is clicked.

Keep ut the good work!

There is a bug in destroy function

Hello Michael,

in jQuery UI 1.8 $.widget are replaced to $.Widget. So to make jQuery UI Multiselect works with both jQuery UI 1.8 and jQuery UI 1.7 you can change

destroy: function() {
this.element.show();
this.container.remove();

$.widget.prototype.destroy.apply(this, arguments);

}

to something like following

destroy: function() {
this.element.show();
this.container.remove();

if ($.Widget === undefined) {
$.widget.prototype.destroy.apply(this, arguments);
} else {
$.Widget.prototype.destroy.apply(this, arguments);
}
}

Best regards
Oleg

Clone

I am cloning a div that contains a multiselect. The HTML looks like this:

1 2

The javascript creates the multiselect as follows:
$("select[multiple='multiple']").multiselect();

Then, the clone is created as follows:

$("div.main").clone(true)

The clone never renders the options. Is this an issue or is there a way around this? Thanks.

methods do not work if multiselect is not visible

Hi,

I have a multiselect that is in a dialog. I would like to set the selected options and then open the dialog. However, due to the :visible qualifier in the code, the select and selectNone methods do not work. I could not decipher why the :visible qualifier is used.

I also had an issue initializing the multiselect if the element and parent were not visible. I added some code to get around this but I am a little stuck with the methods.

Thanks,

Dave

Preserve order of saved items

Hi Michael, great work so far on multiselect.

I like how you can order items before saving. The problem is (to my knowledge), this order can't be preserved without re-arranging the original list.

Here's a potential fix -- allow for some sort of weight (rel) attribute that can be applied to elements. This would allow for the "available" list to remain intact, but also let multiselect know how to order the selected items.

Example:

A B C D

Selected item order:
D, A, C

Thoughts?

Chrome / DataParser with Ajax

Hey,

When using the demo @ http://quasipartikel.at/multiselect_next/ (and on my own site) In Chrome you get an error "Uncaught TypeError: Cannot call method 'split' of undefined" Which relates to the line:

line = lines[i].split("=");

This essentially prevent the remote call from works due to the error and just sits on the "please wait" message when issuing a remote call

Zay

rounding-error so that there might be a white area on the right side

As you can even recognize in the demo, there is a small 1px white area on the right side. Its width is depending on the dividerLocation option. With 0.6 you get a rounding error in Line 60 and 61. You can fix it, with replacing http://github.com/michael/multiselect/blob/master/js/ui.multiselect.js#L61 with:

this.availableContainer.width(this.element.width()-this.selectedContainer.width());

It simply substracts the width of line 60 from the width of the element which gets to a nice result independently of any roundings.

Disable an option

I would like to have an option on the right, not be able to be moved up/down or removed.

Conflict in jquery ui accordion

It seems that if I want to load the multiselect list inside a jqueryui accordion (in a non-active accordion) it does not work at all. What I did is when the accordion containing the multiselect opens up I initialize the multiselect. However, in this case, the drag'n'drop doesn't work.

Maybe some css conflict or something alike..?

Plugin doesn't honor 'disabled' attribute on child OPTION tags

The underlying SELECT used for this plugin has many child OPTION tags, each of which supports a disabled attribute that is set to a boolean - true or false. The plugin doesn't honor that attribute, and allows the user to add or remove items at will from either list witout regard for whether each option is enabled or disabled.

Duplicates Items

I've been able to have the same item appear in both lists (selected and available). When this occurs, the true state is that the item remains unselected. This is verified by sending the selected items in a HTTP GET request and observing (via firebug) that the dup item is not in the request. Unfortunately, I'm unable to reproduce this consistently. If I find more information, I will post. Thanks for this great component. I would love to use it but will have to wait for that issue to be resolved.

Limit the amount of itnes that it is possible to select

Hello everybody,
Firstly congratulations to the creator of this plug-ing, is fantastic.
I wonder if he allows the blocking of the amount of intensity that is possible to select user?
This is for situations in which we have direct interaction of the user inserts directly into the database, so that even believe it faster and easier, simply clciar Add All on instead of selecting items one by one.
Of course avendi able to set the amount, in this case we have to also block the Add All option, because there is not logical to have the Add All because we are limiting the amount of items that can be uncertain.

Now appreciate the response.
Hugs
George Kania

Control loosing its setting

Hi,
I am using the plgin in Asp.net
In my web page,I have a dropdown which causes postback but due to this,the list is distracted until it loads all the items,and then it displays properly.But in the meantime it look odd.
Can we prevent the Select box loosing its state.
Even at http://quasipartikel.at/multiselect_original/ we hit Refresh,the list gets time to have the style attributes

Going other way, can we show 'Loading..'image till all the data is populated?

single removal from the selected list

Hi,
Firstly let me tell you that this is such a wonderful control you developed.
I am using it in my application.And it works well.
Just a single thing I am concerned is,there is 'Remove All' functionality,but how can I remove a single item from the selected list.

Bug - Dragging issue

If I drag an item from the right side to the left and bring it back to the right (so the left side turns yellow) the left side stays yellow and further drags result in a nasty looking overlayed copy of the item, as well as items added having a + icon on the left side where it should be a -. This is on the http://yanickrochon.uuuq.com/multiselect/ version.

"Add all" on fliltered list should only add filtered items

Nice work on this plugin!

The issue I describe above seems to be a usability/expectation issue. When I filter a list, I would expect "Add all" to add all of the items in the filtered list, not all of the unfiltered items as well.

If I have time, perhaps I'll take a shot at a solution, but wanted to see what others thought first.

-Eric

'Starting with ' Search

Hi,
The search option is nice but it is searching the containing item.
I mean if user type r,then it displays all items containing 'r'.
Can I search the items starting with 'r'.
Please look into this.

Destroy no longer works

Hey,

I've been using the newer version of the script for a while and it works great. I was running it on the 1.7.2 Jquery UI and jquery 1.4.2. However since upgrading to the JqueryUI 1.8 and the new 1.8 version you released a few days ago, everything works fine apart from the destroy function no longer works. In Firebug I get the message

$.widget.prototype.destroy is undefined

The Widget disappears but the script actions after this of course no longer work due to the error produced from destroying the multiselect.

I'm still using the method $("#idhere").multiselect('destroy');

Cheers

overflow: auto; problem in IE6

There's a problem now with overflow: auto; for IE6.
I had to remove position: relative, in order to make draggables behave correctly (draggables are slipping behind the ul while dragging if I specify position:relative;).
No idea how to solve that yet.

0 width/height when loading multiselect via AJAX

Let me know if this isn't fixable.

I'm loading an input form dynamically via AJAX. All the javascript (UI, multiselect) gets loaded dynamically also. Everything seems to load just fine, but the actual multiselect area gets shrunken to like 1px.

In the _create() function, this.element.width() and this.element.height() are both returning 0 for the select box. This causes multiselect to become unusable.

A temporary workaround is to hard-code the dimensions, e.g....

    this.container.width(this.element.width()+1);
    this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation));
    this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation)));

    // fix list height to match <option> depending on their individual header's heights
    this.selectedList.height(Math.max(this.element.height()-this.selectedActions.height(),1));
    this.availableList.height(Math.max(this.element.height()-this.availableActions.height(),1));

...to...

    this.container.width(501);
    this.selectedContainer.width(300);
    this.availableContainer.width(200);
    this.selectedList.height(200);
    this.availableList.height(200);

Is there a better workaround?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.