Giter VIP home page Giter VIP logo

Comments (5)

 avatar commented on May 20, 2024

Hello!

I forked your wonderful project, and tweaked it so it wouldn't wipe out the optgroup(s). Basically, check if the option already exists before creating it. If the option exists, just perform your actions on the existing one instead of a new one. I'd prefer to use the main repository if possible, so if this fix is implemented I'll revert back to it!

https://github.com/derekhardison/backbone.stickit/commit/62a1f7bcc6e5f5b552dcdf489038ebef559085fe

Derek

from backbone.stickit.

delambo avatar delambo commented on May 20, 2024

@derekhardison - Another solution might be for stickit to handle another collection data structure. An optgroup could be represented as an ordered hash of labels that map to collections. Since JavaScript doesn't have an ordered hash, an addtional key could be used to map the ordered list of labels. For example:

bindings: {
  modelAttr: 'character',
  'select#tv-characters': {
    collection: function() {
      return {
        'opt_labels': ['Looney Tunes', 'Three Stooges'],
        'Looney Tunes': [{id: 1, name: 'Bugs Bunny'}, {id: 2, name: 'Donald Duck'}],
        'Three Stooges': [{id: 3, name : 'moe'}, {id: 4, name : 'larry'}, {id: 5, name : 'curly'}]
      }
    },
    labelPath: 'name',
    valuePath: 'id'
  }
}

I'm going to sit on this one for a sec. I would love to get some feedback.

from backbone.stickit.

andriijas avatar andriijas commented on May 20, 2024

@delambo looks nice.

from backbone.stickit.

 avatar commented on May 20, 2024

@delambo That's fine too, but only allowing it to be built by stickit makes template systems (such as handlebars) less useful if you're setting up simple static lists of options/optgroups. The ability to do it both ways would be nice.

from backbone.stickit.

delambo avatar delambo commented on May 20, 2024

This is in master. It will go out in the 0.6.1 release, soon.

@derekhardison - one of the major advantages of using stickit is that you don't need to wrestle with template language features or need to write a lot of javascript/configuration in your templates (if any at all - I rarely do!). I find this strategy to be less error prone, easier to configure, and it generally makes developers happier. I'm going to delay support for pre-configured/built lists.

from backbone.stickit.

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.