使用requirejs在数据表上单击事件

时间:2018-11-06 22:10:26

标签: javascript jquery datatables requirejs

数据表单击事件无法与requirejs一起使用,如果我删除了define并将其用作普通js文件的单击事件,则该事件起作用。

错误:未捕获ReferenceError:showImg未定义     在HTMLImageElement.onclick

脚本js:-

define(['jquery','jquery-ui', 'bootstrap', 'bootstrap-treeview',
        'jquery-dateformat', 'datatables.net',
        'dataTables-checkboxes', 'dataTables-buttons'],function($){
// code 
});

配置js:-

requirejs.config({
    "paths" : {
        "app" : "main",
        "jquery" : [ "../lib/js/jquery-3.3.1" ],
        "jquery-ui" : "../lib/js/jquery-ui",
        "bootstrap" : "../lib/js/bootstrap.min",
        "bootstrap-treeview" : "../lib/js/bootstrap-treeview.min",
        "dataTables-buttons" : "../lib/js/dataTables.buttons.min",
        "dataTables-checkboxes" : "../lib/js/dataTables.checkboxes.min",
        "jquery-dateformat" : "../lib/js/jquery-dateformat.min",
        "jquery-migrate" : [ "../lib/js/jquery-migrate-3.0.0.min" ],
        "datatables.net" : [ "../lib/js/jquery.dataTables.min" ],
        "script" : "js/script",
        "search-bar" : "js/search-bar"
    },
    "shim" : {
        // Place for dependencies
        "bootstrap" : {
            deps : [ "jquery", "jquery-ui" ]
        },
        "bootstrap-treeview" : {
            deps : [ "jquery", "bootstrap" ]
        },
        "jquery-dateformat" : {
            deps : [ "jquery" ]
        },
        "jquery-ui" : {
            deps : [ "jquery" ]
        },
        "jquery-migrate" : {
            deps : [ "jquery" ]
        },
        "datatables.net" : {
            deps : [ "jquery", "jquery-ui", "bootstrap", "bootstrap-treeview",
                        "jquery-dateformat"]
            },
        "search-bar" : {
            deps : [ "jquery", "jquery-ui", "bootstrap", "bootstrap-treeview",
                    "jquery-dateformat", "datatables.net",
                    "dataTables-checkboxes", "dataTables-buttons" ]
        },
        "script" : {
            deps : [ "jquery", "jquery-ui", "bootstrap", "bootstrap-treeview",
                    "jquery-dateformat", "datatables.net",
                    "dataTables-checkboxes", "dataTables-buttons" ],
                    exports: 'DataTable'

        }
    }
});
requirejs([ "app" ]);

0 个答案:

没有答案