thesnarkie Posted November 27, 2009 Report Posted November 27, 2009 var Cpages = { request:function(url, div, page){ $.ajax({ beforeSend:function(){ $(".ajax_loading").show(); $(".pnavig_parent").hide(); }, url: url, success: function(txt){ $(".ajax_loading").hide(); $(".pnavig_parent").show(); $(".pnavigMactive").removeClass().addClass("pnavigM"); $(".pnavigM a[id='" + page + "']").addClass("pnavigMactive"); $(div).html(txt); }, error: function(txt){ $(".ajax_loading").hide(); $(".pnavig_parent").show(); $(div).html(txt); } }); } } $(".pnavigM a[id=" + page + "]").addClass("pnavigMactive"); - es biju domājis, ka viņš pievienos to class pie pnavigM, kur tagam a id = page, bet viņš pievieno to class pie a taga. kā uztaisīt, ka viņš pievieno tam, kam biju domājis? Quote
rATRIJS Posted November 27, 2009 Report Posted November 27, 2009 $("a#" + page).parent(".pnavigM").addClass("pnavigMactive"); Quote
thesnarkie Posted November 27, 2009 Author Report Posted November 27, 2009 o, paldies ratrij! :) Quote
thesnarkie Posted November 29, 2009 Author Report Posted November 29, 2009 .js var Comment = { onCommentSubmit:function( el, url, targetEl ) { var data = $(el).serialize(); var type = "POST"; Star.ajax( type, el, url, data, targetEl ); return false; } } var Star = { ajax:function( type, el, url, data, targetEl ) { $.ajax({ type: type, beforeSend:function(){ $(el).children(".button_parent").hide(); $(el).children(".ajax_loader").show(); }, url: url, data: data, success:function(txt){ $(el).children(".ajax_loader").hide(); $(el).children(".button_parent").show(); if(txt == "OK") { loadContents(targetEl, "/p_gamma/news/rq/r_latest_comments.php?id=" + $(el).children("input[name='id']").val()); } }, error:function(txt){ $(el).children(".ajax_loader").hide(); $(el).children(".button_parent").show(); } }); return false; } } <form method="post" id="add_comment" action="/p_gamma/news/" onsubmit="Comment.onCommentSubmit(this, '/p_gamma/news/rq/p_comments.php', '#ncomment_response'); return false;"> <input name="id" type="hidden" value="<? echo $get_news['id'] ?>" /> <textarea class="textarea" cols="25" name="comment" rows="4" onkeyup="Comment.remainingChars(this, event);"></textarea> <input type="submit" id="submit_comment" value="Add comment" /> </form> Vai kopumā pareizi js/jquery lietas? Kaut ko uzlabot, saisināt? Bet problēma man ir šāda: loadContents(targetEl, "/p_gamma/news/rq/r_latest_comments.php?id=" + $(el).children("input[name='id']").val()); Kā lai iegūst el (=>this => tātad formas) input, kura name=id vērtību? Man viņš atgriež undefined, jo man kaut kas smagi nesanāk ar šito: $(el).children("input[name=id]").val(), bet viss pārējais darbojas. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.