未捕获的TypeError:对象[object Object]在'nyromodal'Popup中使用它时没有方法'validationEngine'?

时间:2013-04-23 05:51:35

标签: jquery jquery-validation-engine nyromodal

在这里我有一个像下面这样的情况我想在nyromodal内部使用jquery验证引擎插件。如果我没有使用它与nyromodal意味着它在这里工作正常一些屏幕拍摄我所拥有的... ..........

This will Show the validation prompt This Will Show The Error In FireBug

这是我的代码:

<?php
require_once'../session.php';
?>
<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml' >
<head>
    <title>HTML Form Builder</title>
    <link rel='stylesheet' type='text/css' href='<?php echo ROOT_PATH;?>css/validationEngine.jquery.css'/> 

<script type="text/javascript" src="<?php echo ROOT_PATH;?>js/jquery.min.1.7.1.js">
</script>
<script type="text/javascript" src="<?php echo ROOT_PATH;?>js/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="<?php echo ROOT_PATH;?>js/jquery.validationEngine.js"></script>
    <script type='text/javascript'>
    $(function(){
        changeInnerHTML('doctor_id');
        changeInnerHTML('hospital_id');
        changeInnerHTML('clinic_id');
        changeInnerHTML('stockist_id');
        changeInnerHTML('chemist_id');
        changeInnerHTML('bloodbank_id');
        changeInnerHTML('dialysis_id');
        if($('#refSubmit').val() == 'grid')
        {
            $('#submit-form').hide();
        }
        $('form').attr('autocomplete','off');
        //$('form').attr('id','addForm');
        $('form').removeAttr('novalidate');
    });
    function changeInnerHTML(id)
    {
        if($('#dialog_box_'+id).length)
        {
            var tmp=id.split('_');
             $.get('getDataValues.php?ref='+tmp[0],function(data,status){
                $('#dialog_box_'+id).html(data);
            });
        }
    }
    $('#submit-form').live('click',function(){
        $('#preview_form').validationEngine('validate')?subForm():'';
    });
    function subForm()
    {
        $('#preview_form').submit();
    }
    </script>
    </head>
    <body>
    <div id='container'>


        <h1 id="form-name" style="background-color: rgb(255, 255, 255); box-shadow: rgba(0, 0, 0, 0.247059) 0px 1px 3px; border: none; margin: 8px 15px;">dfgdfg</h1>
        <form method="POST" action="saveData.php" id="preview_form" novalidate="novalidate">


        <div class="row" style="display: block;"><label class="field" for="textfield_1">textfield_1<div class="rqrd">*</div></label><span class="textField" data=""><input type="text" id="dialog_box_textfield_1" name="textfield_1" class="validate[required]" /></span></div><input type="button" class="button blue" value="Submit" id="submit-form"/><input type='hidden' id='tname' name='tname' value='surveyForm_2' /><input type='hidden' id='refSubmit' name='refSubmit' value='<?php echo $_GET['ref'];?>' /></form></div> <!--container-->

</body>
</html>

1 个答案:

答案 0 :(得分:1)

您需要将jQuery代码包装在$(document).ready(function() { });$(function() { });中,以便让它看到整个DOM以及使用on()代替live,因为live在jQuery版本1.9 +

中被弃用并完全删除
$(document).ready(function() {
    $('#submit-form').on('click',function(){
        $('#preview_form').validationEngine('validate')?subForm():'';
    });    
});

另一件事是确保所有文件的路径都正确定位。