javascript - firing js before submitting remote bootstrap modal rails form -


i have rails4 app. i'm trying remote submission inbuilt ajax mechanism (respond_to format.js , create.js.erb), before submit form want change code bit via js save proper utc time db.

everything works fine till last line, default behavior pervented, time formatted momentjs, form doesn't submitted in end. wrong $('#new-task-modal-form').submit(); line? else miss here?

form

<%= form_for([current_user, @task], remote: true, id: "new-task-modal-form") |f| %> .... .... <%= f.submit "create task", class: 'btn btn-primary new-task-submit', "data-sid" => current_user.id, "data-rip" => :executor_id %> 

js

var ready = function() {    $('.new-task-submit').on('click', function (e){     e.preventdefault();     var localmoment = moment($('.new-task-deadline').val());     $('.new-task-deadline').val(localmoment.toisostring());     $('#new-task-modal-form').submit();   });  $(document).ready(ready); $(document).on("page:load", ready); 

i tried way well, momentjs can't problem:

var ready = function() {    $('.new-task-submit').on('click', function (e){     e.preventdefault();     $('#new-task-modal-form').submit();   });  $(document).ready(ready); $(document).on("page:load", ready); 

this bootstrap modal issue. it's weird had call submit function on modal not on rails form: $('#newtask').submit();.

<%= form_for([current_user, @task], remote: true, class: "new-task-modal-form") |f| %> <div class="modal fade" id="newtask" tabindex="-1" role="dialog" aria-labelledby="mymodallabel"> 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -