casp
casp

Reputation: 35

Jquery: Dropkick plugin - Form submit onchange

Hi i get a form without button submit, who work very well without Dropkick and send by POST method a variable called "fonction":

<form name="recherche_cat" method="post" class="ass_select">
<select name="fonction" onchange='submit()' tabindex="3" size="1">
    <option value="default">default</option>
    <option value="1">mot1</option>
    <option value="2">mot2</option>
</select>
</form>

But when i used dropkick, it does'nt work anymore. I try this:

$('.ass_select').dropkick({
  change: function (value, label) {
  $(this).closest('form').submit();
  }
});

Page reload but without post the value.

Thanks for help.

Upvotes: 0

Views: 1091

Answers (3)

Rahul Gupta
Rahul Gupta

Reputation: 10141

You can do this:

$('.ass_select').dropkick({
  change: function (value, label) {
      $(this.form).submit();//changed here
  }
});

Upvotes: 0

casp
casp

Reputation: 35

I found my problem. I should not add the dropkick class (on my example class="ass_select") on the form, but on the select. Like this the submit is alright.

Upvotes: 0

Fabr&#237;cio Matt&#233;
Fabr&#237;cio Matt&#233;

Reputation: 70169

Your onchange='submit()' no longer fires because jQuery does not warrant firing handlers attached without jQuery.

Instead, assuming you have that submit function declared, use:

$('.ass_select').dropkick({
  change: submit
});

Fiddle

Note that inside the handler, this points to the form instead of the select element now.

Upvotes: 0

Related Questions