对象[object Object]没有方法' bootstrapValidator'

时间:2014-08-05 15:41:48

标签: jquery

的index.html

<script type="text/javascript" data-main="js/app/main.js" src="js/libs/require/require.2.1.14.min.js"></script>

main.js

require.config({
    baseUrl: "js/",
    paths: {
        bootstrap: "libs/bootstrap/bootstrap.min",
        bootstrapValidator: "libs/bootstrap/validator",
        jquery: "libs/jquery/jquery-1.9.0.min",
        jqueryui: "libs/jquery-ui-1.11/jquery-ui.min",
        modernizr: "libs/modernizr/modernizr.2.8.3.min",
        underscore: "libs/underscore/underscore",
        text: "libs/require/text"
    },
    shim: {
        jquery: {
            exports: "$"
        },
        bootstrapValidator: {
            deps: ["jquery"]
        }
    }
});

require([
    "bootstrap",
    "underscore",
    "bootstrapValidator",
    "text!/js/app/templates/index.html"], function(Bootstrap, _, BootstrapValidator, IndexTemplate) {
    "use strict";

    var App = {
        $el: $('#content-latch'),

        /*
         * initialize: constructor
         * @returns the instance
         */
        initialize: function() {

            // create an instance of the main form template
            var html = _.template($(IndexTemplate).html());

            // set the main el to the html
            this.$el.html(html);

            setTimeout(function() {
                $('#profileForm').bootstrapValidator({});
            }, 500);
        }

    };

    return App.initialize();
});

我已经读过线程标题是由jQuery被包含两次引起的,但是我看不到上面的代码如何

1 个答案:

答案 0 :(得分:0)

您的jQuery包含错误的顺序:

 paths: {
        jquery: "libs/jquery/jquery-1.9.0.min",
        jqueryui: "libs/jquery-ui-1.11/jquery-ui.min",
        bootstrap: "libs/bootstrap/bootstrap.min",
        bootstrapValidator: "libs/bootstrap/validator",
        /*  jquery: "libs/jquery/jquery-1.9.0.min",
            jqueryui: "libs/jquery-ui-1.11/jquery-ui.min", */