2017-06-26 33 views
0

我有一个控制器(Laravel),这将是动态创建一个形式如下Laravel动态表单提交没有响应

<div class="row" style="margin-bottom:30px;margin-top:20px;"> 
    <div class="col-2"> 
    <form class="addform" id="newcheckform" role="form"> 
     '.csrf_field().' 
    <label class="" for="cust_code">Cust Code</label> 
    <input type="text" class="form-control" id="cust_code" value="'.$row->cust_no.'"> 
    </div> 
    <div class="col-2"> 
    <label class="" for="cust_short">Cust Shortname</label> 
    <input type="text" class="form-control" id="cust_short"> 
    </div> 
    <div class="col-4"> 
    <label class="" for="cust_name">Cust Name</label> 
    <input type="text" class="form-control" id="cust_name" value="'.$row->cust.'"> 
    </div> 
    <div class="col-2"> 
     <label class="" for="region">Region</label> 
    <input type="text" class="form-control" id="region"> 
    </div> 
    <div class="col-2"> 
     <label class="" for="region">Add Cust Data</label> 
    <button class="btn btn-sm btn-info" id="createnewcust" type="submit">Create</button> 
    </form> 
    </div> 
</div> 

如果将通过下面的脚本在叶片文件

$("#custcheck").load("{{ url('/sales/admin/custcheck') }}"); 

被加载显示的形式应该是。 但是,当我提交按钮。什么都没发生。代码如下。欣赏任何人都可以提供帮助。此脚本驻留在相同的刀片文件中。

$(function() { 
    $(document).on('submit', '#newcheckform', function(e){ 
     alert("Hi"); 
    }); 
}); 
+2

您的窗体关闭标记错误。你在div内启动了'

',并在'div'外部关闭了首先检查 –

+0

对不起,但我无法让你知道。启动它的正确方法是什么? – Wahsei

+0

现在明白了,对我来说这是一个简单而容易的错误。我将表单重新定位到顶部并关闭在div底部。 – Wahsei

回答

1

您有<form>改变这样的错误关闭标签:

<div class="row" style="margin-bottom:30px;margin-top:20px;"> 
    <form class="addform" id="newcheckform" role="form"> 
    {{csrf_field()}} 
    <div class="col-2"> 
    <label class="" for="cust_code">Cust Code</label> 
    <input type="text" class="form-control" id="cust_code" value="{{$row->cust_no}}"> 
    </div> 
    <div class="col-2"> 
    <label class="" for="cust_short">Cust Shortname</label> 
    <input type="text" class="form-control" id="cust_short"> 
    </div> 
    <div class="col-4"> 
    <label class="" for="cust_name">Cust Name</label> 
    <input type="text" class="form-control" id="cust_name" value="{{$row->cust}}"> 
    </div> 
    <div class="col-2"> 
    <label class="" for="region">Region</label> 
    <input type="text" class="form-control" id="region"> 
    </div> 
    <div class="col-2"> 
    <label class="" for="region">Add Cust Data</label> 
    <button class="btn btn-sm btn-info" id="createnewcust" type="submit">Create</button> 
    </div> 
    </form> 
</div> 

这将工作。

+1

这个问题谢谢。有效! – Wahsei

+0

很好,恭喜 –