mercredi 6 juillet 2016

Ajax call after rendering template

I have select on which I make an Ajax call:

JS for view

$(document).ready(function() {

  $('#select').on('change', function() {
    $.ajax({
     ...
    });
  });

});

And this Ajax call populates the select with options.

Then when I go to my create action, I render this template once again:

def create
  if @job.save
    ...
  else
    render 'new'
  end
end

After that Ajax doesn't execute. $(document).ready won't trigger my clicks.

What can I do?

Aucun commentaire:

Enregistrer un commentaire