Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获类型错误:无法读取属性';应用';未定义日期选择器的定义_Javascript_Ruby On Rails_Ruby On Rails 4_Datepicker - Fatal编程技术网

Javascript 未捕获类型错误:无法读取属性';应用';未定义日期选择器的定义

Javascript 未捕获类型错误:无法读取属性';应用';未定义日期选择器的定义,javascript,ruby-on-rails,ruby-on-rails-4,datepicker,Javascript,Ruby On Rails,Ruby On Rails 4,Datepicker,我的应用程序在同一方面有两个问题,抽象视图如下: 该应用程序允许用户查看不同的视频剪辑。在后端/管理部分,管理员可以跟踪任何特定剪辑组的视图。例如,管理员可以选择环球影城,选择一个日期范围:开始日期:2015-01-1,结束日期:2016-01-1,然后点击过滤器,查看在此范围内收到的环球总视图数 问题是,例如,日期选择器不再工作,因此当我单击日期字段时,没有日历出现,我必须手动输入日期。对于两个,我只得到了最远的结果:2015-10-18和2016-02-18。当我输入2015-09-18或任

我的应用程序在同一方面有两个问题,抽象视图如下:

该应用程序允许用户查看不同的视频剪辑。在后端/管理部分,管理员可以跟踪任何特定剪辑组的视图。例如,管理员可以选择
环球影城
,选择一个
日期范围:开始日期:2015-01-1,结束日期:2016-01-1
,然后点击
过滤器
,查看在此范围内收到的
环球
总视图数

问题是,例如,日期选择器不再工作,因此当我单击日期字段时,没有日历出现,我必须手动输入日期。对于两个,我只得到了最远的结果:
2015-10-18
2016-02-18
。当我输入
2015-09-18
或任何更早的内容时,它不会生成结果

下面是我单击Chorme中的inspect element时出现的错误

错误:未捕获类型错误:无法读取未定义的属性“应用”

 */
 (function($) {
   var _datepicker = jQuery.fn.datepicker;

   $.fn.datepicker = function(options) {
    var $date = _datepicker.apply(this, arguments); <--- this line
根据Robs点更新:

custom.js

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require jquery-ui/draggable
//= require jquery-ui/sortable
//= require jquery-ui/autocomplete
//= require bootstrap
//= require carousel.js
//= require hover.js
//= require menu_js/modernizr.js
//= require menu_js/dlmenu.js
//= require custom.js
//= require bootstrap-tabs.js
//= require jquery.raty.js
//= require letsrate.js
//= require rails-timeago
//= require tinymce-jquery
//= require scrollTo.js
//= require clips.js
//= require jquery.sticky.js
//= require jquery-ui.min.js
//= require jquery.dynatable.js
//= require playlist.js
//= require index.js.coffee
/**
 * Constructor patch for jQuery UI DatePicker
 * Automatically initializes the input with the value from the altField
 */
 (function($) {
   var _datepicker = jQuery.fn.datepicker;

   $.fn.datepicker = function(options) {
    var $date = _datepicker.apply(this, arguments);

    if (options.altFormat && options.altField) {
      var altValue = $(options.altField).val();
      var value = $.datepicker.parseDate(options.altFormat, altValue);
      var dateFormat = _datepicker.call(this, 'option', 'dateFormat');
      $(this).val($.datepicker.formatDate(dateFormat, value));
    }
  };
})(jQuery);

var $date = $("#search_start_date");

$date.datepicker({
  dateFormat: "yy-mm-dd",
  altFormat: "yymmdd"
});

var $end_date = $('#search_end_date');

$end_date.datepicker({
  dateFormat: "yy-mm-dd",
  altFormat: "yymmdd"
});



});
index.html.erb

<%= form_for Search.new, url: statistics_search_saas_admin_statistics_path, html: {method: :get, remote: true} do |f| %>
<table id="table_1" class="table" style="margin-bottom: 5px;">
  <tr>
    <th style="color: black; background: white; border-color: white;">Studio</th>
    <th style="color: black; background: white; border-color: white;">Film</th>
    <th style="color: black; background: white; border-color: white;">Clip</th>
    <th style="color: black; background: white; border-color: white;"></th>
    <th style="color: black; background: white; border-color: white;"></th>
  </tr>
  <tr>
  <td>
    <select multiple id="studio_select" style="height: 150px;">
      <% Studio.all.each do |studio| -%>
      <option value="<%=studio.id %>"><%= studio.name %></option>
      <% end -%>
    </select>
    <%= hidden_field_tag :studio_ids %>
  </td>
  <td>
    <select multiple id="film_select" style="height: 150px;"></select>
    <%= hidden_field_tag :film_ids %>
  </td>
  <td>
    <select multiple id="clip_select" name="search[clip]" style="height: 150px;"></select>
    <%= hidden_field_tag :clip_ids %>
  </td>
</table>

<div class="span10">
<table class="table">
  <tr>
    <th>Beginning Date</th>
    <th>End Date</th>
    <th></th>
  </tr>
  <tr>
    <td><%= f.text_field :start_date, value: 1.month.ago.strftime('%Y-%m-%d')  %></td>
    <td><%= f.text_field :end_date, value: Time.now.strftime('%Y-%m-%d') %></td>
    <td>
      <%= f.submit "Filter", class: "btn btn-danger", data: {disable_with: 'Searching...'} %>
      <%= link_to 'Clear Form', '#', id: "clear", class: 'btn btn-default'  %>
    </td>
  </tr>
</table>
</div>
<% end -%>

演播室
胶卷
夹子
开始日期
结束日期

谢谢@RobG,我的道歉本可以更清楚!在OP中添加了一个更新。希望对您有所帮助,您是否介意分享有关如何解决此问题的任何想法?干杯您有
if(options.altFormat&&options.altField)
,但我在传递给options的对象中没有看到altField属性,因此它总是错误的。干杯,请分享一个适当的代码示例来说明您的观点。谢谢我不知道正确的代码,我看不到足够的代码。有一个
$(options.altField).val()
,它推断options.altField应该为表单控件返回一个选择器。我在标记中看不到
$(“\search\u start\u date”)
引用的元素,也看不到options.altField应该引用什么。