jquery validation script not resetting when another ajax call is made
hey, I'm using a jquery plugin and when i focus in on a field and focus out it alerts me of a validation error.
now in my set up I have a menu that loads content from another page via ajax, and with in that content I have another sub menu that also calls content in with another ajax request.
Scenario
I click on Files from main menu, then click on View from sub menu, then on Create from there (using another ajax request)
on the Create content is where I am using the validation plugin, so like I said when I focus in and out it works, BUT if I click on Files again from the main menu the validation error remain in place where they popped up. If i click on View from the sub menu then the validation error fade out.
I tried to isolate the issue as to why the error fade out with an ajax call from the sub menu but now with the main menu.
Main menu script:
//------------------------------------------------------------------
// Pidget menu
//------------------------------------------------------------------
var content = '#main-content',
wrap = '#wrap';
$("nav a.files-menu-link").live('click', function({
$.validationEngine.closePrompt('.formError',true);
$(content).hide(200, function(){
$(wrap).load('files.php' + content, function(){
$(this).hide().html(data).slideDown(500);
});
})
return false;
});
sub menu script
$('a#prospect-file-link').live('click', function(){
$.validationEngine.closePrompt('.formError',true);
$.post('resources/ajax/ajax.php', {
action : 'prospects',
uid : uid
}, function(data){
$('#files-right-pane').hide().html(data).slideDown(500);
$(".alpha").click(function() {
$(this).find("span").toggleClass("expand-alpha-down");
$(this).next(".show").slideToggle();
return false;
});
});
return false;
});
then the create new script
//-- Create new prospect
$('a.new-prospect').live('click', function(){
$('#files-right-pane').fadeOut(200);
$.post('resources/ajax/ajax.php', {
action : 'create_prospect',
uid : uid
}, function(data){
$('#files-right-pane').hide().html(data).slideDown(500);
selectBox('prospect-type', '开发者_JAVA百科prospect-type-td');
selectBox('status', 'status-td');
selectBox('primary-number', 'primary-td');
selectBox('secondary-number', 'secondary-td');
mce('new-prospect-comments');
$("#new-prospect-form").validationEngine();
$('.state').autoSuggest('resources/ajax/suggest.php', {minChars: 2, matchCase: false, startText: '', asHtmlID: 'state'});
});
return false;
});
html markup
...
<td><input type="text" id="first_name" name="first_name" class="validate[required]" /></td>
<td><input type="text" id="middle_name" name="middle_name" /></td>
<td><input type="text" id="last_name" name="last_name" class="validate[required]" /></td>
...
Thats my setup, I can't figure out the .closePromp() works in the view but not with the main menu link
Looks to me like you are missing a parenthesis after 'function('.
Instead of:
$("nav a.files-menu-link").live('click', function({
it should be:
$("nav a.files-menu-link").live('click', function(){
精彩评论