Comments (6)
I have tried update the attribute 'data-bsm-order' to the current order but it doesn't work:
jQuery("#myselect option[selected=selected]").each(function(i, option) {
jQuery(option).attr( "data-bsm-order", i);
});
from bsmselect.
it would really help if you can come with a runnable example (ie a plunker) and describe the observed vs desired behavior. Thanks.
from bsmselect.
This is one example: https://jsfiddle.net/vj13191t/3/
At the beginning:
- 1- G
- 2- D
Move D to 1:
- 1- D
- 2- G
Add X from the input and the result is:
- 1- G
- 2- D
- 3-X
But I think it would be so:
- 1- D
- 2- G
- 3- X
from bsmselect.
Thanks for the fiddle.
The problem is that the sortable plugin does not update the the data-bsm-order
when an option is added or when the list is re-ordered.
One solution would be to update the plugin (onChange
and onSort
) to set or update this order.
An other solution would be to use: addItemTarget: 'bottom'
and render the option in the desired order in the original select.
from bsmselect.
I've also tried updating parameters "data-bsm-order" before adding the new option , but did not work:
jQuery("#add_button").click(function() {
jQuery("#myselect option[selected=selected]").each(function(i, option) {
jQuery(option).attr( "data-bsm-order", i);
});
....
});
from bsmselect.
You should try to do it in the sortable plugin and probably want to do jQuery(option).data('bsm-order', i)
from bsmselect.
Related Issues (20)
- missing default order HOT 15
- Drag and drop doesnt work in ie9 HOT 4
- bsmSelect doesn't update its values when it is called again and its select options have changed HOT 2
- During animation, long text wraps then unwraps HOT 3
- Multiple selects but each has the same disabled items HOT 1
- bsmSelect(sortable) + overflow-y:scroll + firefox: list items disappearing when moving HOT 12
- Unable to save sort order of listbox HOT 17
- Object doesn't support property or method 'init' HOT 1
- How to change "title" dynamically HOT 4
- addItemTarget: 'original' sort order not preserved HOT 1
- A few issues (Not animating, not retaining sort order)... latest jquery. HOT 7
- Selecting item by typing includes multiple items. HOT 3
- pre-selecting items during page load and cannot control order HOT 10
- On change event '$(this).val()' display previous value HOT 10
- After AJAX update, change event fails HOT 6
- How to allow up to 3 selections ? HOT 1
- Wrong behavior on Example Number 2 at the demo page HOT 3
- Not working properly with latest jquery.js
- Is this plugin still maintained? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bsmselect.