PDA

View Full Version : مشکل واقعا عجیب در تداخل کدهای من !!!!



beh9am
پنج شنبه 20 آذر 1393, 17:04 عصر
سلام

من 2 تا کد دارم که وقتی همزمان در سایت استفاده میکنم هیچ کدوم کار نمیکنن ولی اگر تک به تک استفاده کنم مشکلی ندارن و کار میکنن !!!


یکیش اینه :





// Login Form

$(function() {
var button = $('#loginButton');
var box = $('#loginBox');
var form = $('#loginForm');
button.removeAttr('href');
button.mouseup(function(login) {
box.toggle();
button.toggleClass('active');
});
form.mouseup(function() {
return false;
});
$(this).mouseup(function(login) {
if(!($(login.target).parent('#loginButton').length > 0)) {
button.removeClass('active');
box.hide();
}
});
});






و یکیش هم اینه :





jQuery(document).ready(function($){
jQuery.noConflict();

// initialise
var form, err, reply;
function acp_initialise() {
jQuery('#commentform').after('<div id="error"></div>');
jQuery('#submit').after('<img src="'+acp_path+'loading.gif" id="loading" alt="'+acp_lang[0]+'" />');
jQuery('#loading').hide();
form = jQuery('#commentform');
err = jQuery('#error');
reply = false;
}
acp_initialise();

jQuery('.comment-reply-link').live('click', function() {
// checks if it's a reply to a comment
reply = jQuery(this).parents('.depth-1').attr('id');
err.empty();
});
jQuery('#cancel-comment-reply-link').live('click', function() {
reply = false;
});

jQuery('#commentform').live('submit', function(evt) {
err.empty();

if(form.find('#author')[0]) {
// if not logged in, validate name and email
if(form.find('#author').val() == '') {
err.html('<span class="error">'+acp_lang[1]+'</span>');
return false;
}
if(form.find('#email').val() == '') {
err.html('<span class="error">'+acp_lang[2]+'</span>');
return false;
}
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(!filter.test(form.find('#email').val())) {
err.html('<span class="error">'+acp_lang[3]+'</span>');
if (evt.preventDefault) {evt.preventDefault();}
return false;
}
} // end if
if(form.find('#comment').val() == '') {
err.html('<span class="error">'+acp_lang[4]+'</span>');
return false;
}

jQuery(this).ajaxSubmit({

beforeSubmit: function() {
jQuery('#loading').show();
jQuery('#submit').attr('disabled','disabled');
}, // end beforeSubmit

error: function(request){
err.empty();
var data = request.responseText.match(/<p>(.*)<\/p>/);
err.html('<span class="error">'+ data[1] +'</span>');
jQuery('#loading').hide();
jQuery('#submit').removeAttr("disabled");
return false;
}, // end error()

success: function(data) {
try {
// if the comments is a reply, replace the parent comment's div with it
// if not, append the new comment at the bottom
var response = jQuery("<ol>").html(data);
if(reply != false) {
jQuery('#'+reply).replaceWith(response.find('#'+re ply));
jQuery('.commentlist').after(response.find('#respo nd'));
acp_initialise();
} else {
if (jQuery(document).find('.commentlist')[0]) {
response.find('.commentlist li:last').hide().appendTo(jQuery('.commentlist')). slideDown('slow');
} else {
jQuery('#respond').before(response.find('.commentl ist'));
}
if (jQuery(document).find('#comments')[0]) {
jQuery('#comments').html(response.find('#comments' ));
} else {
jQuery('.commentlist').before(response.find('#comm ents'));
}
}
form.find('#comment').val('');
err.html('<span class="success">'+acp_lang[5]+'</span>');
jQuery('#submit').removeAttr("disabled");
jQuery('#loading').hide();

} catch (e) {
jQuery('#loading').hide();
jQuery('#submit').removeAttr("disabled");
alert(acp_lang[6]+'\n\n'+e);
} // end try

} // end success()

}); // end ajaxSubmit()

return false;

}); // end form.submit()
}); // end document.ready()






چجوری میشه هر 2 تا اینارو استفاده کنم و مشکلی پیش نیاد ؟

پیشاپیش تشکر از وقتی که برای پاسخ و رفع مشکل بنده میزارید