我用通知模式开发了一个简单的页面,该页面将编辑和删除“客户端”,当我按下“编辑”按钮时,我捕获了laravel对象并获取数据,我将数据放在字段中进行编辑,但我想生成一个Jquery形式的动作。我的代码是下一个:
client.blade
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Edición de Cliente</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="panel-body">
<form data-parsley-validate="true" action="#enter code here" id="update_client" method="get" >
{{ csrf_field() }}
<div class="form-group row m-b-15">
<label class="col-md-4 col-sm-4 col-form-label">Nombre:</label>
<div class="col-md-8 col-sm-8">
<input class="form-control" type="text" id="nameu" name="name" data-parsley-required="true" placeholder="Nombre completo" value="" />
</div>
</div>
<div class="form-group row m-b-15">
<label class="col-md-4 col-sm-4 col-form-label">NIT/CI:</label>
<div class="col-md-8 col-sm-8">
<input class="form-control" type="text" id="nitu" name="nit" data-parsley-type="digits" placeholder="NIT o CI" data-parsley-required="true" value=""/>
</div>
</div>
<div class="form-group row m-b-15">
<label class="col-md-4 col-sm-4 col-form-label">Teléfono:</label>
<div class="col-md-8 col-sm-8">
<input class="form-control" type="text" id="telu" name="tel" data-parsley-type="digits" placeholder="Teléfono" data-parsley-required="true" value=""/>
</div>
</div>
<div class="form-group row m-b-15">
<label class="col-md-4 col-sm-4 col-form-label">Fax:</label>
<div class="col-md-8 col-sm-8">
<input class="form-control" type="text" id="faxu" name="fax" data-parsley-type="digits" placeholder="Fax" value=""/>
</div>
</div>
<div class="form-group row m-b-15">
<label class="col-md-4 col-sm-4 col-form-label">Celular:</label>
<div class="col-md-8 col-sm-8">
<input class="form-control" type="text" id="celu" name="cel" data-parsley-type="digits" placeholder="Celular" value="" />
</div>
</div>
<div class="form-group row m-b-15">
<label class="col-md-4 col-sm-4 col-form-label">Dirección:</label>
<div class="col-md-8 col-sm-8">
<input class="form-control" type="text" id="addru" name="addr" data-parsley-required="true" placeholder="Dirección" value=""/>
</div>
</div>
<div class="form-group row m-b-15">
<label class="col-md-4 col-sm-4 col-form-label">Correo Electrónico:</label>
<div class="col-md-8 col-sm-8">
<input class="form-control" type="text" id="emailu" name="email" data-parsley-required="true" data-parsley-type="email" placeholder="Correo Electrónico" value="" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a href="javascript:;" class="btn btn-white" data-dismiss="modal">Close</a>
<button type="submit" class="btn btn-danger" id="btn-save" value="add">Actualizar</button>
</div>
</form>
</div>
jquery
$(document).on("click", "#edit", function(){
var code = JSON.parse($(this).val());
$("#nameu").val(code.client_name);
$("#nitu").val(code.client_nit);
$("#telu").val(code.client_telephone);
$("#faxu").val(code.client_fax);
$("#celu").val(code.client_cellphone);
$("#addru").val(code.client_address);
$("#emailu").val(code.client_email);
var action = "{{action('ClientController@update',[ '$id' => "+code.client_id+" ])}}";
$( "#update_client" ).attr( "action", action );
});
当我按下操作按钮时,出现“ http://myipserver/client/+code.client_id+”
答案 0 :(得分:0)
由于您是从浏览器中的JS获取client_id的,因此刀片文件中的Laravel action()帮助器将无法使用它。
如何使用纯URL代替action()帮助器?
var action = "/client/"+code.client_id;