Answer the question
In order to leave comments, you need to log in
Why jQuery script only fires after page reload?
Good afternoon everyone. There was a problem: to create a date and time form in the application, I use the jquery datetimepicker function. The script works, but only after reloading the page - it does not work on the first load (when you click on the form, the calendar does not jump out). What could be the problem and how to solve it?
application.css:
......
*= require bootstrap
*= require rails_bootstrap_forms
*= require font-awesome
*= require jquery-ui
*= require jquery-ui.structure
*= require jquery-ui.theme
*= require jquery .datetimepicker
*= require_tree .
*= require_self
*/
application.js:
......
//= require jquery
//= require jquery-ui
//= require jquery.datetimepicker.full
//= require jquery_ujs
//= require custom
//= require twitter/bootstrap
//= require moment
//= require turbolinks
//= require_tree .
Answer the question
In order to leave comments, you need to log in
Rails 4 Subtleties - Turbolinks
Use the following code in application.js:
var ready;
ready = function() {
//Ваша функция
};
$(document).ready(ready);
$(document).on('page:load', ready);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question