简体   繁体   English

jQuery qtip“不是函数”-Ruby on Rails

[英]Jquery qtip “is not a function” - Ruby on Rails

I'm trying to get qtip to work with rails FullCalendar, but haven't been able to get past the error "is not a function" when setting up a qtip. 我正在尝试让qtip与rails FullCalendar一起使用,但是在设置qtip时无法克服错误“ is not a function”。 I'm just getting back in to Jquery/Rails and apparently this is typically a js file load issue. 我只是回到Jquery / Rails,显然这通常是一个js文件加载问题。 However, it seems like the js files are being loaded properly (in correct order and only once). 但是,似乎js文件已正确加载(以正确的顺序并且只能加载一次)。 Here are (some of) my js files: 这是(一些)我的js文件:

<script src="/assets/jquery.self-d03a5518f45df77341bdbe6201ba3bfa547ebba8ed64f0ea56bfa5f96ea7c074.js?body=1" data-turbolinks-track="true"></script>
<script src="/assets/jquery_ujs.self-8e98a7a072a6cee1372d19fff9ff3e6aa1e39a37d89d6f06861637d061113ee7.js?body=1" data-turbolinks-track="true"></script>
<script src="/assets/jquery.qtip.self-c86ab2c0151d0748df498fc4603ec759f565e7966405872bad084728da15c92c.js?body=1" data-turbolinks-track="true"></script>

Looks to me like the js files are loading properly. 在我看来,js文件已正确加载。 I placed the calendar in application.js for now: 我现在将日历放在application.js中:

//= require jquery
//= require jquery_ujs
//= require jquery.qtip.js

$(document).ready(function(){
    $("#calendar").fullCalendar({
        eventSources : [{
            url: 'url_to_get_data'
        }],
        eventLimit: true,
        eventRender: function(event, element) {
            element.qtip({
                content: event.description
            });
        }
     });
});

I pulled this eventRender example straight from the FullCalendar's eventRendering section . 我直接从FullCalendar的eventRendering部分提取了这个eventRender示例。 This won't work even if I try to put a qtip on an input . 即使我尝试在inputinput qtip,这也行不通。

Anyone see anything glaringly wrong? 有人看到明显的错误吗?

Ended up just solving this myself, so wanted to post the answer for anyone with the same issue. 最终只是自己解决了这个问题,因此想将答案发布给遇到相同问题的任何人。 It turns out that I had to download The Qtip .js file and place it in assets/javascripts, as well as still include it in the application.js file. 事实证明,我必须下载Qtip .js文件并将其放置在资产/ javascript中,并且仍将其包含在application.js文件中。 I guess I mistakenly thought that rails would just do this for me. 我想我误以为Rails会为我做这件事。

Not sure if it matters, but the order of my require statements look like this: 不确定是否重要,但是我的require语句的顺序如下所示:

//= require jquery2
//= require jquery_ujs
//= require moment
//= require fullcalendar
//= require jquery.qtip.js

One last thing - I did have to modify the code from the original example . 最后一件事-我确实不得不修改原始示例中的代码。 Here is my modified code, checking for nulls: 这是我修改后的代码,检查空值:

$(document).ready(function(){
    $("#calendar").fullCalendar({
        eventSources : [{
            url: 'url_to_get_data'
        }],
        eventLimit: true,
        eventRender: function(event, element) {
            if (element && event.description) {
            element.qtip({
                content: event.description,
                hide: {
                    fixed: true,
                    delay: 500
                }
            });
        }
        },
        eventClick: function(calEvent, jsEvent, view) {
            // Open in new window
            url = window.location.href;
            window.open(url + "/" + calEvent.id);
        },
        eventMouseover: function(event, jsEvent, view) {
            // Todo
        },
        eventMouseout: function(event, jsEvent, view) {
            // Todo
        },
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM