2012-03-07 90 views
1

我有我的CMS文件这个jQuery功能:为什么我的jquery淡入/淡出功能停止工作?

/* ************************************* */ 

// JQuery Function calls: 

$(document).ready(function(){ 

    // Fade message 
    $(".message").css({display: "none"}).fadeIn(1000); 


    // Show/Hide table details (Plugin Management page and similar tables) 
    $(".table_drop_down").click(function() { 
     var target = $(this).parents("tr").next("tr"); 
     target.fadeToggle(); 
     return false; 
    }); 

    // Hide table details (Plugin Management page and similar tables) 
    $(".table_hide_details").click(function() { 
     $(this).parents("tr.table_tr_details").fadeOut(); 
     return false; 
    }); 

    // Show/Hide forgot password form 
    $(".forgot_password").click(function() { 
     var target = $("#forgot_password_form"); 
     target.fadeToggle(); 
     return false; 
    }); 

    // Show/Hide generic 
    $(".show_hide").click(function() { 
     var target = $(".show_hide_target"); 
     target.fadeToggle(); 
     return false; 
    }); 

}); 

// Show/Hide forgot password form突然停止工作。

这是php文件的一部分,其中其称为:

<a href="#" class="forgot_password">Forgot password?</a> 
<form id="forgot_password_form" style="display: none;" name='forgot_password_form' action='<?php echo BASEURL; ?>index.php' method='post'> 
    <?php echo $h->lang['user_signin_login_forgot_password_submit_instruct_1']; ?> 
<table> 
    <tr> 
    <td><?php echo $h->lang["user_signin_account_email"]; ?>&nbsp; </td> 
    <td><input type='text' size=30 name='email' value='<?php echo $email_check; ?>' /></td> 
    <td><input type='submit' class='submit' value='<?php echo $h->lang['user_signin_login_forgot_password_submit']; ?>' /></td> 
    </tr>    
</table> 
<input type='hidden' name='forgotten_password' value='true'> 
<input type='hidden' name='page' value='login'> 
<input type='hidden' name='csrf' value='<?php echo $h->csrfToken; ?>' /> 
    <?php echo $h->lang['user_signin_login_forgot_password_submit_instruct_2']; ?> 
</form> 

这是样式声明

#forgot_password_form { 
    display: none; 
} 

它停止较早前的工作,我不知道为什么,我点击了链接,似乎没有发生。

有没有人在这里看到错误?

在控制台上的错误

target.fadeToggle is not a function 
...rget");target.fadeToggle();return false;});});$.extend({URLEncode:function(c){va... 

控制台调试头我此行

var ajax=Array();var returnvalue=Array();jQuery.fn.fadeToggle=function(speed,easing,callback){return this.animate({opacity:'toggle'},speed,easing,callback);};$(document).ready(function(){$(".message").css({display:"none"}).fadeIn(1000);$(".table_drop_down").click(function(){var target=$(this).parents("tr").next("tr");target.fadeToggle();return false;});$(".table_hide_details").click(function(){$(this).parents("tr.table_tr_details").fadeOut();return false;});$(".forgot_password").click(function(){var target=$("#forgot_password_form");target.fadeToggle();return false;});$(".show_hide").click(function(){var target=$(".show_hide_target");target.fadeToggle();return false;});});$.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;while(x<c.length){var m=r.exec(c.substr(x));if(m!=null&&m.length>1&&m[1]!=''){o+=m[1];x+=m[1].length;}else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;},URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;while((m=r.exec(o))!=null&&m.length>1&&m[1]!=''){b=parseInt(m[1].substr(1),16);t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;}});function handleEnter(field,event){var keyCode=event.keyCode?event.keyCode:event.which?event.which:event.charCode;if(keyCode==13){return false;} 
+0

该代码似乎工作得很好 - 检出这个jsfiddle - > http://jsfiddle.net/GBBE9/。我会说别的地方坏了卢卡斯。 – willdanceforfun 2012-03-07 04:20:20

+0

js工作正常... http://jsfiddle.net/YrNGA/1/是jquery文件的工作?控制台中的错误是什么? – 2012-03-07 04:22:54

+0

这很伤心。 – 2012-03-07 04:25:24

回答

1

如果被称为正在通过某种AJAX的执行你的PHP文件,你可能会想尝试改变你的点击功能,以这样的:

如果使用jQuery 7+

// Show/Hide forgot password form 
    $(".forgot_password").on("click",function() { 
    var target = $("#forgot_password_form"); 
    target.fadeToggle(); 
    return false; 
}); 

如果您使用的是较旧的jQuery,请尝试使用live()而不是on()。

+0

'使用'$(“。forgot_password”)。on不是函数 ..._target“); target.fadeToggle(); return false;}) ;}); $。extend({URLEncode:function(c)...'unsing live'target.fadeToggle is not a function ... e_target“); target.fadeToggle(); return false;});} ); $。extend({URLEncode:function(c ...' – 2012-03-07 04:41:19

+0

你运行的是什么版本的jquery? – willdanceforfun 2012-03-07 04:43:54

+0

我在我的头文件中有这个' ' – 2012-03-07 04:52:15