bug重现:
每次我登录 系统时,第一次 选择级联菜单时,比如选择 山东省, 他就会报tajax error错 跳转到首页。 而再次重新选择级联菜单时, 再选择山东省,就会 在下一级输出 济南、青岛等市一级。
这个问题困扰了很久,以为 触发什么事件,但js水平不高,排了好几次,都这样。昨晚上 无聊 又排了下 。发现 是因为 <a href='http://gaoce19871026.blog.163.com/#' ></a> 这里的问题,所幸 把下面标红色的 # ,改为 javascript:void(0);,就ok了
return this.each(function(i){
var $this = $(this).removeClass("combox");
var name = $this.attr("name");
var value= $this.val();
var label = $("option[value=" + value + "]",$this).text();
var ref = $this.attr("ref");
var refUrl = $this.attr("refUrl") || "";
var cid = $this.attr("id") || Math.round(Math.random()*10000000);
var select = '<div class="combox"><div id="combox_'+ cid +'" class="select"' + (ref?' ref="' + ref + '"' : '') + '>';
select += '<a href="javascript:" class="'+$this.attr("class")+'" name="' + name +'" value="' + value + '">' + label +'</a></div></div>';
var options = '<ul class="comboxop" id="op_combox_'+ cid +'">';
$("option", $this).each(function(){
var option = $(this);
options +="<li><a class=\""+ (value==option[0].value?"selected":"") +"\" href=\"#\" value=\"" + option[0].value + "\">" + option[0].text + "</a></li>";
});
options +="</ul>";
$("body").append(options);
$this.after(select);
$("div.select", $this.next()).comboxSelect().append($this);
if (ref && refUrl) {
这个问题困扰了很久,以为 触发什么事件,但js水平不高,排了好几次,都这样。昨晚上 无聊 又排了下 。发现 是因为 <a href='http://gaoce19871026.blog.163.com/#' ></a> 这里的问题,所幸 把下面标红色的 # ,改为 javascript:void(0);,就ok了
return this.each(function(i){
var $this = $(this).removeClass("combox");
var name = $this.attr("name");
var value= $this.val();
var label = $("option[value=" + value + "]",$this).text();
var ref = $this.attr("ref");
var refUrl = $this.attr("refUrl") || "";
var cid = $this.attr("id") || Math.round(Math.random()*10000000);
var select = '<div class="combox"><div id="combox_'+ cid +'" class="select"' + (ref?' ref="' + ref + '"' : '') + '>';
select += '<a href="javascript:" class="'+$this.attr("class")+'" name="' + name +'" value="' + value + '">' + label +'</a></div></div>';
var options = '<ul class="comboxop" id="op_combox_'+ cid +'">';
$("option", $this).each(function(){
var option = $(this);
options +="<li><a class=\""+ (value==option[0].value?"selected":"") +"\" href=\"#\" value=\"" + option[0].value + "\">" + option[0].text + "</a></li>";
});
options +="</ul>";
$("body").append(options);
$this.after(select);
$("div.select", $this.next()).comboxSelect().append($this);
if (ref && refUrl) {
在DWZ框架中,当使用级联菜单时,首次选择特定选项(如山东省)会导致错误并跳转到首页。经过排查,问题出在`<a>`标签的`href`属性上,原本的`#`导致了错误。修复方法是将`href`改为`javascript:void(0);`,从而避免页面跳转,正常显示下一级菜单(如济南市、青岛市)。

258

被折叠的 条评论
为什么被折叠?



