Coder Social home page Coder Social logo

Comments (6)

intropedro avatar intropedro commented on August 25, 2024

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.

vicb avatar vicb commented on August 25, 2024

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.

intropedro avatar intropedro commented on August 25, 2024

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.

vicb avatar vicb commented on August 25, 2024

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.

intropedro avatar intropedro commented on August 25, 2024

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.

vicb avatar vicb commented on August 25, 2024

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)

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.