vazco / meteor-universe-autoform-select

Meteor universe autoform select
MIT License
16 stars 10 forks source link

How to limit number of selected items? #10

Closed wietsevr closed 9 years ago

wietsevr commented 9 years ago

Thanks for the code - works like a charm.

I accept multiple items at the moment, but I'd need to limit the number of items accepted to a maximum. Anyone who can help me? Thanks :)

MichalW commented 9 years ago

hmm. I think You can add event:

'change select': function (e) 

and check in this function length of elements: $(e.target).val().length

wietsevr commented 9 years ago

I'll try it out, thanks for your help.

rizafahmi commented 9 years ago

@MichalW I did add an event and check the length of elements. But I have no idea what to do next. Please help.

  'change select': function (e) {
    var number_selected = $(e.target).val().length;

    if (number_selected >= 2) {
      // what to do?
    }

  }
MichalW commented 9 years ago

@wietsevr: @rizafahmi: I added just new option: 'values_limit'. Please look at the readme and test

rizafahmi commented 9 years ago

Nice @MichalW . Thanks for this package!