In a recent project to do, learn to use layui development back office systems.
But I encountered a pit while doing editing form.
There will be a pop when you click Edit.
We need to pass values from the parent form to the child form. value content is passed to subform
layer.open ({ of the type: 2 , title: "Edit Administrator" , Content: "Admin_edit the above mentioned id =?" + e.data.id, Area: [ "420px" , "420px" ], btn: [ "OK" , "Cancel " ], yes : function(e, t) {
After this step, we encountered a pit, always thought pop jsp file is run on the child window. Val () with the value of var data = $ ( "# id")., not found on the identification data obtained.
Later, the next Baidu, found that taking a child window pop value is the value of the parent window needs to extract the child window.
else if ("edit" === e.event) { t(e.tr); layer.open({ type : 2, title : "编辑管理员", content : "Admin_edit?id="+e.data.id, area : [ "420px", "420px" ], btn : [ "确定", "取消" ], yes : function(e, t) { /*var l = window["layui-layer-iframe"+ e], r = "LAY-user-back-submit", n = t.find("iframe").contents().find("#"+ r); l.layui.form.on("submit("+ r + ")",function(t) { t.field; layer.msg(i); console.log("sssssssss"); i.reload("LAY-user-front-submit"), layer.close(e) }), n.trigger("click");*/ var id = parent.layer.getChildFrame('#id').val(); var username = parent.layer.getChildFrame('#username').val(); var password = parent.layer.getChildFrame('#username').val(); alert(username); $.post("Admin_save",{ id:id, username:username, password:password }, function(data){ if(data.code==200){ //location.reload(); i.reload('LAY-user-back-manage'); layer.msg ( "modified successfully" ); layer.close (E); } the else { layer.msg ( "request failed!" ); } }) }, Success: function ( e, t) { } }) } })
The method of the parent window is a child window value var password = parent.layer.getChildFrame ( '# username ') val ().;
This can be achieved by layui js editor.