首页 > 代码库 > 通过html的data属性取值

通过html的data属性取值

先贴代码

 1 function(obj, url){ 2         var params = {}; 3         var target_id = obj.attr("id"); 4         if(typeof(url) == "string" && url.search(/\?/)>=0){ 5             $.each(url.split("?")[1].split("&"), function(){ 6                 var keyVal = this.split("="); 7                 if(keyVal[0] && keyVal[1]){ 8                     params[decodeURIComponent(keyVal[0])] = decodeURIComponent(keyVal[1]); 9                 }10             });11             url = url.split("?")[0];12         }13 14         if(obj.hasClass("refresh-target")){15             obj.data("load-url", url);16             obj.data("load-params", params);17             obj.data("auto-refresh-load-url", url);18             obj.data("auto-refresh-load-params", params);19         }20 21         if(target_id === "container") {22             obj.esfContentsPublish(url, params);23         } else {24             var dfd = $.Deferred();25             if(target_id !== "action_panel" && 26                 target_id !== "inner_contents" && 27                 target_id !== "tree_panel") {28                 esf_fw.effects.screen_mask();29             }30 31             // reject auto refresh32             esf_fw.auto_refresh.reject(dfd);33             34             obj.fjLoad({url: url, params: params, dfd: dfd});35             dfd.done(function(){36                 $("<div>").fjPublish("/esf_fw.data.load/complete", [obj]);37                 esf_fw.effects.screen_unmask();38             });39         }40 }
View Code

 

通过html的data属性取值