Javascript 尝试在发生单击但缺少参数列表时添加输入字段
我尝试在单击某个元素时使用laravel的Form helper添加输入字段Javascript 尝试在发生单击但缺少参数列表时添加输入字段,javascript,php,jquery,laravel-4,Javascript,Php,Jquery,Laravel 4,我尝试在单击某个元素时使用laravel的Form helper添加输入字段 $('#segment-create').click(function(e){ $('#segments').append("<div class='clearfix'> <div class='selectbox boxed pull-left'> {{ Form::selectopt('contact_property[]', [ 'class' => 'for
$('#segment-create').click(function(e){
$('#segments').append("<div class='clearfix'> <div class='selectbox boxed pull-left'> {{ Form::selectopt('contact_property[]', [ 'class' => 'form-control pull-left', 'rel' => 'noresize' ], [ 'User Activity' => [ 'Clicked in the last' => 'clicked_last', 'Opened in the last' => 'opened_last', 'Not clicked in the last' => 'not_clicked_last', 'Not opened in the last' => 'not_opened_last' ], 'User Property' => [ 'City' => 'city', 'Age' => 'opened_last', 'Name' => 'name' ] ] ) }} <span class='pull-left' style=' width:50px; text-align:center; line-height:34px;'>is</span> <div class='selectbox boxed pull-left'> {{ Form::select('operator[]', array('0' => '=', '1' => '>', '2' => '≥', '3' => '<', '4' => '≤', '5' => '<>' ), null, ['class' => 'operator form-control pull-left']); }} <span class='pull-left' style=' width:50px; text-align:center; line-height:35px;'>to</span> <div class='pull-left'> {{ Form::text('value[]', null, ['class' => 'filter-name form-control', 'placeholder' => 'Filter value']) }} </div> <div class='pull-left'><a href='#' class='right cbx-filter cbx cbx-checked filter-checkbox'> </a> </div> </div> </div> </div>");
e.preventDefault();
// to check as complete todo list
shoot({segment_name:$('#new-segment-name').val()}, 'POST');
});
$(“#段创建”)。单击(函数(e){
$(“#段”)。追加({Form::selectopt('contact#property[],['class'=>'表单控件左拉','rel'=>'noresize'],['User Activity'=>['Clicked in the last'=>'Clicked#last','Opened in last'=>'Opened#last','Not Clicked#Clicked#last'>'Not Clicked#Clicked#last','User property'=>['City'=>'City','Age'=>'Open_last','Name'=>'Name']]])}是{{Form::select('operator[]',array('0'=>'=','1'=>'>,'2'=>'≥', '3'=>'对我来说,在javascript中附加太多HTML代码不是个好主意。
作为解决方案,我建议创建一个新的刀片文件,如果需要,您将对其进行渲染,然后附加渲染文件
$('#segment-create').click(function(e){
$.get('/url-to-remder-html', function(answ) {
$('#segments').append(answ);
});
e.preventDefault();
// to check as complete todo list
shoot({segment_name:$('#new-segment-name').val()}, 'POST');
}))
或者尝试在代码的这一部分使用常规HTML。这不是增加http请求吗?在您的情况下,这是最好的解决方案。或者您可以将HTML代码隐藏起来,然后在需要时获取并附加。