Giter Club home page Giter Club logo

Comments (9)

ivaynberg avatar ivaynberg commented on May 27, 2024

not possible right now. the .id key is hardcoded. we would need a new option where a function can be specified that would get back the id and then all the places that access it via .id would need to be replaced with a call to that function. there are a lot of places like that, so this will be a rather large change.

from select2.

ProLoser avatar ProLoser commented on May 27, 2024

Damn. This is a necessary change for me. Any notes you can provide to this endeavor would help. At the very least, it would be good if I can get it to support a string value, and not necessarily a function.

It would pretty much mean anywhere you refer to id just refer to opts.data.id instead, which would default to id of course.

from select2.

ProLoser avatar ProLoser commented on May 27, 2024

For now I've gotten around this limitation by doing:

formatResult: function (employee) {
    employee.id = employee.eid;
    return '<strong>' + employee.fullName + '</strong>' + employee.email;
},

However I still feel quite adamantly that this should be fixed. It could cause problems for situations where .id is already in use for other purposes (which is the case for myself) and since it's destructive to the data.

from select2.

ProLoser avatar ProLoser commented on May 27, 2024

Turns out my fix does not work for the first selected value. After that, all subsequent values show the proper 'eid' instead. Really need proper support for this.

from select2.

ivaynberg avatar ivaynberg commented on May 27, 2024

going to work on this soon.

from select2.

ivaynberg avatar ivaynberg commented on May 27, 2024

try the branch above and let me know if it works well for you.

you can set a new id option which can either be a string representing the id key or a function(choice)

from select2.

ProLoser avatar ProLoser commented on May 27, 2024

Cool appears to be working in my tests so far

from select2.

ivaynberg avatar ivaynberg commented on May 27, 2024

i will merge this later today unless you find something wrong with it.

from select2.

ivaynberg avatar ivaynberg commented on May 27, 2024

merged into master

from select2.

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.