0

I have removed turbolinks from application.js and I am working on an AngularJS project. In a form where I have some select2 dropdowns and some datetimepickers, the JS code doesn't load If I don't refresh the page.

I have also added data-no-turbolinks in my links (despite I disabled turbolinks) but the issue still occurs. I am working on development environment.

My JS file:

var ready;
ready = function() {

  // DateTime pickers for Start time, End time
  $(function () {
      $('#dtp_start_time').datetimepicker();
      $('#dtp_end_time').datetimepicker();
  });

  // Select2 box for search select boxes in Outage form
  $(".search_select").select2();

};

$(document).ready(ready);
$(document).on('page:load', ready);
$(document).on('page:change', ready);

From my experience with Rails, loading JS in such ways is a pain, so how do I make it work ?

||||||
  • put this code in separate js file rather than putting any controller – Shubham Nigam Dec 1 '15 at 9:15
  • @ShubhamNigam what do you mean ? It is in its own file and //= require file.js by application.js. – Radolino Dec 1 '15 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.