Answer the question
In order to leave comments, you need to log in
Why can't call methods of connected js plugins in RoR?
Good day!
Given:
ready = ->
$('.clockpicker').clockpicker
$('.datepicker-inline').datepicker
$(document).ready(ready)
$(document).on('turbolinks:load', ready)
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'#, '~> 5.1'
# Use Puma as the app server
gem 'puma'
# Use SCSS for stylesheets
gem 'sass-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
#template
gem 'slim-rails'
gem 'simple_form'
gem 'client_side_validations'
gem 'client_side_validations-simple_form'
gem 'clockpicker-rails'
gem 'bootstrap-datepicker-rails'
gem 'devise-bootstrap-views'
#users
gem 'devise'#, git: 'https://github.com/gogovan/devise.git', branch: 'rails-5.1'
gem 'devise-i18n'
# gem 'high_voltage'
## seo
gem 'meta-tags'
gem 'friendly_id'
# gem 'mongoid', '~> 6.1.0'
gem 'flag_shih_tzu'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen'
gem 'better_errors'
gem 'pg'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
group :production do
# gem 'mysql2', '~> 0.3.18'
end
Answer the question
In order to leave comments, you need to log in
The problem was that it was not correctly hanging handlers to call plugin methods. It was necessary like this:
ready = ->
$('.clockpicker').clockpicker
$('.datepicker-inline').datepicker
$(document).ready(ready)
$(document).on('turbolinks:load', ready)
Why don't you use jQuery datepicker?
app/assets/javascripts/application.js:2
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require jquery-ui/i18n/datepicker-uk
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Конечная дата фильтрации
$( '#date_start' )
.val GetSession $sessionKey, 'date_start'
.data 'old-value', GetSession $sessionKey, 'date_start'
.datepicker onSelect: ->
$this = $( @ )
$thisVal = $this.val( )
if $thisVal isnt $this.data 'old-value'
SetSession $sessionKey, 'date_start', $thisVal
$this.data 'old-value', $thisVal
$dateEnd = $( '#date_end' )
$dateEndVal = $dateEnd.val( )
if not $dateEndVal || moment( $thisVal, $formatDate ).isAfter( moment( $dateEndVal, $formatDate ) )
SetSession $sessionKey, 'date_end', $thisVal
$dateEnd.val( $thisVal ).data 'old-value', $thisVal
filterTable( ) # Фильтрация таблицы документов
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question