1 Replies - 1180 Views - Last Post: 13 May 2014 - 05:47 AM

#1 Mr_P  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 07-July 13

Chosen.js maxselected event not firing

Posted 13 May 2014 - 04:23 AM

I am using the jquery chosen.js plugin http://harvesthq.github.io/chosen/ and have set the limit that a user can select as 5 using {max_selected_options}. However, I would like to trigger an alert if a user tries to select more than 5. I have tried the follwoing code, but that does nothing. Can someone show me the correct way to code this as it is driving me nuts.

Thanks

jquery code

$(function() { 
$("#box_rtv").chosen({

 width: "250px",
 max_selected_options: 5

 });
 });
 $("#box_rtv").bind("chosen:maxselected", function () { alert("You can only select up to 5 boxes"); });
 $("#box_rtv").chosen().change( function () { alert("You can only select up to 5 boxes"); } );


html code

<div class="fieldset">
    <h1><span>Select Box(es) Reference</span></h1>
      <p>
        <select data-placeholder="Choose a box..." multiple required="required" class="chosen-select" name="box_rtv[]" id="box_rtv">
          <option value=""></option>
        </select>
      <span></span>
        <a style="margin-left: 12px;" href="javascript:void(0)" class="brtvhelp">Help</a>
      </p>
</div>


Is This A Good Question/Topic? 0
  • +

Replies To: Chosen.js maxselected event not firing

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,028
  • Joined: 08-June 10

Re: Chosen.js maxselected event not firing

Posted 13 May 2014 - 05:47 AM

hm, its somewhat difficult to choose more than one option if there is only one option ...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1