jtable的验证引擎无法工作Uncaught TypeError:$(...)。live不是函数

时间:2015-11-08 07:23:23

标签: javascript php codeigniter jtable twig

我正在使用一个使用PHP + jTable + twig模板的网站。当我使用validationengine添加一些验证时,使用chrome的开发人员工具

会让我出错
  

"未捕获的TypeError:$(...)。live不是函数"

     

" Uncaught TypeError:form.find(...)。not(...)。die不是函数"

我按照http://www.jtable.org/Demo/UsingWithValidationEngine2

上的所有说明操作

我已经包含了验证引擎的Javascript和CSS文件

{% block template_libs_js %}
{{ parent() }}
        <script src="{{ theme_path }}plugins/jQueryUI/jquery-ui.min.js"></script>
        <script src="{{ mdasset_path_js }}jquery.jtable.js"></script>
        <script src="{{ mdasset_path_js }}jquery.validationEngine-en.js"></script>
        <script src="{{ mdasset_path_js }}jquery.validationEngine.js"></script>
{% endblock %}

for CSS

{% block head %}
{{ parent() }}
    <meta name="description" content="Halaman Master Data yang hanya dapat diakses oleh administrator">

    <link href="{{ core_asset_path_css }}jquery-ui.css" rel="stylesheet" type="text/css" />
    <link href="{{ mdasset_path }}themes/metro/blue/jtable.css" rel="stylesheet" type="text/css" />
    <link href="{{ mdasset_path_css }}validationEngine.jquery.css" rel="stylesheet" type="text/css" />

{% endblock %}

这是我的主要代码

{% block template_js_jquery %}
{{ parent() }}
        //Prepare jTable
        $('#cntRefAsisten').jtable({
            title: 'Ref. Asisten',
            paging: true,
            sorting: true,
            defaultSorting: 'nama_asisten ASC',
            selecting: true, //Enable selecting
            multiselect: true, //Allow multiple selecting
            selectingCheckboxes: true, //Show checkboxes on first column
            //selectOnRowClick: false, //Enable this to only select using checkboxes
            actions: {
                listAction: '{{ site_url() }}masterdata/ref_asisten/fetch',
                createAction: '{{ site_url() }}masterdata/ref_asisten/add',
                updateAction: '{{ site_url() }}masterdata/ref_asisten/save',
                deleteAction: '{{ site_url() }}masterdata/ref_asisten/del'
            },
            fields: {
                id: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false
                },
                nama_asisten: {
                    title: 'Nama Asisten',
                    width: '30%',
                    inputClass: 'validate[required]'
                },
                keterangan: {
                    title: 'Keterangan',
                    type: 'textarea',
                    width: '20%'
                }
            },
            //Initialize validation logic when a form is created
            formCreated: function (event, data) {
                data.form.validationEngine();
            },
            //Validate form when it is being submitted
            formSubmitting: function (event, data) {
                return data.form.validationEngine('validate');
            },
            //Dispose validation logic when form is closed
            formClosed: function (event, data) {
                data.form.validationEngine('hide');
                data.form.validationEngine('detach');
            }
        });

        //Load list from server
        $('#cntRefAsisten').jtable('load');
{% endblock %}

1 个答案:

答案 0 :(得分:2)

.live()已被弃用,自jQuery 1.7开始。您应该使用.on()代替。

$("#a").live("click)......

应改为

$("document").on("click","#a",function() {
    ....
});