根据前两个下拉框的值去动态渲染第三个下拉框的值
- 效果
- 前端代码
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Url')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-url" data-rule="required" data-field="url" data-params='{"custom[p_id]":"","custom[r_id]":""}' data-source="website/selectpage" class="form-control selectpage" name="row[url]" type="text" value="">
</div>
</div>
- JS代码
add: function () {
// 二级联动查询
$("#c-url").data("params",function(obj)
{
if( $("#c-project").val() != "" && $("#c-region").val() != "" )
{
return {custom: {p_id: $("#c-project").val(), r_id: $("#c-region").val()}};
}
else
{
return false;
};
});
$("#c-url").data("format-item", function(row){
return row.name + " - " + row.url;
});
Controller.api.bindevent();
},