Closed andrey-lizunov closed 8 years ago
@andrey-lizunov If you use https://github.com/Semantic-Org/Semantic-UI not with the gem, it works?
@doabit It looks like submit doesn't pass params only if I trigger this event on form in "onAdd" callback
If you use https://github.com/Semantic-Org/Semantic-UI not with the gem, it works?
Will check it right now.
@doabit Here is small example https://jsfiddle.net/andreylizunov/5bbum10m/15/
@andrey-lizunov Hi, if you want to upload file with ajax in rails, you must use https://github.com/JangoSteve/remotipart or https://github.com/malsup/form.
@doabit I don't try to upload files, it's simple select with options.
And for some reasons, submit on form in "onAdd" callback don't pass params from this semantic-ui multiple select. I don't have same problem with non multiple selects, when I trigger submit on form in "onChange" callback.
And yes, I use Rails and form has remote: true
parameter.
@andrey-lizunov Sorry, my mistake, I've tested and it works
<form id="test_form" action="/test" data-remote="true" method="get">
<select name="locations[]" id="locations" class="ui fluid search dropdown" multiple="">
<option value="9961">Russia, Tver</option>
<option value="9483">Russia, Moscow</option>
<option value="9440">Russia, Saint Petersburg</option>
</select>
</form>
<script type="text/javascript">
$(function(){
$('#locations').dropdown({
onAdd: function(value) {
console.log(value)
$("#test_form").submit()
}
}
)
})
</script>
42: def test
=> 43: binding.pry
44: end
[1] pry(#<PostsController>)> params
=> <ActionController::Parameters {"locations"=>["9961", "9483"], "controller"=>"posts", "action"=>"test"} permitted: false>
@doabit Hm, strange, because I still have empty params in same case(( But anyway, maybe it because of some my mistake in code. And I find another way, wich works in my case, it's handle the "change" event on select and trigger submit from there. Thx for your help, Sean!
@andrey-lizunov You're welcome.
I have form with semantic-ui dropdown with these classes "ui fluid search dropdown selection multiple" and the problem, that form submit doesn't pass params from this dropdown to my server. But dropdowns without "multiple" param works fine in same case. I make submit on "onAdd"