keiG Posted October 12, 2012 Report Share Posted October 12, 2012 (edited) Tātad ar jquery load ielādēta php lapa, kurā iekšā ir dropdown ar name="category". saitā ir jquery skripts $("select[name=category]").change{....} bet ielādētais saturs nereagē uz šo skriptu! Kā šo varētu labot? Edited October 12, 2012 by keiG Quote Link to comment Share on other sites More sharing options...
marrtins Posted October 12, 2012 Report Share Posted October 12, 2012 Varbūt Tu attačo par agru? http://api.jquery.com/live/ Quote Link to comment Share on other sites More sharing options...
keiG Posted October 12, 2012 Author Report Share Posted October 12, 2012 Ja, domā šādi $("select[name=category]").live("change",function(){.....}) tad arī izmēģināju, bet neiet. Load notiek pirms šī koda! Quote Link to comment Share on other sites More sharing options...
marrtins Posted October 12, 2012 Report Share Posted October 12, 2012 Varbūt iemet pilnu kodu? Quote Link to comment Share on other sites More sharing options...
keiG Posted October 12, 2012 Author Report Share Posted October 12, 2012 (edited) Visu noteikti nevaru iemest, jo tas ir ļoti daudz, bet kādu daļu varbūt. Daļa no index lapas jquery $(".edit").click(function(){ $("#editcont").html('<br/><div style="text-align:center"><img src="icons/loader.gif"></div>'); var editid = $(this).attr("id"); $("#editid").attr("value",editid); $('#editcont').load('edit.php?id='+editid+"&token=<?php echo $token?>"); // Te tiek ielādēta lapa //////////////////////////////////////////////// $("#bkg,#edit_menu").fadeIn(500); }); $("select[name=categoryedit]").live(change,function(){ alert('Yes'); $("#subcategoryedit").html(""); var cid = $(this).attr("value"); var items = [<?php $res = mysql_query("SELECT * from `subcategory`"); $row = mysql_fetch_array($res,MYSQL_ASSOC); while($row = mysql_fetch_array($res,MYSQL_ASSOC)){echo "[".$row["id"].",'".$row["name"]."'],"; } ?>] var i=1; var string=""; var subc=0; string+= 'Subcategory:<br/><select name="subcategoryedit" class="input"><option value=0 >...</option>'; while(i<=items.length){ if(items[i-1][0]==cid){ subc++; var sel=""; string += "<option value='"+i+"'>"+items[i-1][1]+"</option>"; }; i++; } if(subc>0){$("#subcategoryedit").html(string+"</select><br/><br/>");}else{$("#subcategoryedit").html("");}; }); Fragments no ielādētās lapas: <div id="subcategoryedit"> Sub category:<br/><select name="subcategoryedit" class="input"> <option value="0" >...</option> <?php $res2 = mysql_query("SELECT * from `subcategory` order by id ASC"); while($row2 = mysql_fetch_array($res2,MYSQL_ASSOC)){ if($re['subcategory']==$row2["subid"]){$sel = "selected";}else{$sel="";}; if($row2['id']==$re['category']){echo "<option value=".$row2["id"]." ".$sel." >".$row2["name"]."</option>";}; } ?> </select> </div> Edited October 12, 2012 by keiG Quote Link to comment Share on other sites More sharing options...
codez Posted October 12, 2012 Report Share Posted October 12, 2012 1)ja DOM objekti vēl nav ielādēti, tiem nevar piešķirt eventus, tāpēc izmantojam: $(function(){ //šeit viss, kam notikt pēc lapas DOM ielādes }); 2)Eventu deleģēšanai nezimantojam live, bet on uz parent elementu: $('.parent').on('click','.child',function(){ }); kur .parent iepriekš ielādēt DOM elemnents, bet .child var būt brīvi izveidoti DOM elementi jebkurā laikā Quote Link to comment Share on other sites More sharing options...
keiG Posted October 12, 2012 Author Report Share Posted October 12, 2012 (edited) Laikam vienkāršāk būs ar ajax saņemt tikai mainīgos un visu formu pārcelt index lapā! Jebkurā gadījumā paldies par palīdzību :) Edited October 12, 2012 by keiG Quote Link to comment Share on other sites More sharing options...
briedis Posted October 15, 2012 Report Share Posted October 15, 2012 Tak iemācies lietot $.on un miers. Bez šī nu nekāda normāla kodēšana ar jQ nesanāks... http://api.jquery.com/on/ Quote Link to comment Share on other sites More sharing options...
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.