Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with onchange: 'this.form.submit() #113

Open
yshmarov opened this issue Jan 7, 2021 · 3 comments
Open

Does not work with onchange: 'this.form.submit() #113

yshmarov opened this issue Jan 7, 2021 · 3 comments

Comments

@yshmarov
Copy link

yshmarov commented Jan 7, 2021

My code:
= select_tag :movie_id, options_for_select(Movie.map{|c| [c.to_s, c.id]}), { onchange: 'this.form.submit()', class: 'chosen-select' }

Expected behaviour:
having added onchange: 'this.form.submit()', whenever a value is selected the form gets submitted.

Current behaviour:
does not work with onchange: 'this.form.submit()'

@yshmarov
Copy link
Author

yshmarov commented Jan 7, 2021

actually, adding onchange: 'this.form.submit()' to the javascript kind of helps:

(function() {
  $(function() {
    return $('.chosen-select').chosen({
      onchange: 'this.form.submit()',
      allow_single_deselect: true,
      no_results_text: 'No results matched',
      width: '200px'
    });
  });

}).call(this);

@buncis
Copy link

buncis commented Sep 3, 2022

what is ur rails version? did using this.form.requestSubmit() helps?

@kashiftufail
Copy link

In Rail 7

  <%= f.select :city, ["Berlin", "Chicago", "Madrid"] , {include_blank: "none"} ,onchange: "this.form.requestSubmit()" %>

  <%= f.collection_select :user_id, User.all,:id,:email,{include_blank: "none"} , {onchange: "this.form.requestSubmit()"} %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants