layui渲染下拉框,动态设置下拉框的内容,获取下拉框自定义属性

layui渲染下拉框,设置下拉框,设置验证

 

关键代码:设置需要渲染的下拉框,用 lay-filter
id=“department_id” lay-filter=“department_id”

js代码如下:

layui.use(['form','layer'], function(){
        	  var form = layui.form;
        	  
        	  //监听提交
        	  form.on('submit(formDemo)', function(data){
        	    return true;
        	  });
        	  
        	  getChamber($('#department_id').val());  
          	form.on('select(department_id)', function(data){
              	var department_id=(data.value);
              	getChamber(department_id);
          	});

          	
          	function getChamber(department_id){
          		$("#chamber_id").html("");
          		 form.render('select');
          		if($.trim(department_id).length==0)return;
             		 $.ajax({
            	                type: 'POST',
            	               url : "${ctx}/chamber/selectByDid",
	  			    			data : {
	  			    				department_id : department_id
	  			    			},
            	                dataType:  'json',
            	                success: function(data){
  	           	                $.each(data, function(key, val) {
  	           								var option1 = $("

Layui 监听 select 获取自定义属性值

form.on('select(doctor_id)', function(data){
            	var f= $(data.elem).find("option:selected").attr("data-f");
            	$('#money').val(f); 
            	 
        	}); 

你可能感兴趣的:(layui动态修改下拉框,layui二级下拉框,layui获取自定义属性,layui设置二级下拉框)