aika Posted January 7, 2012 Report Share Posted January 7, 2012 Palīdziet lūdzu nounifice't sekojošu koda fragmentu tā lai, lietojot vienu dialoga formu, varētu iedarboties uz dažādiem elementiem $( "#b_..." ) būs vairāki , attiecīgi katram vajadzētu apendot attiecīgu ... kkā vajadzētu padot mainīgo uz dialogu? vai arī ir kādas citas idejas? $( "#b_competition" ) .button() .click(function() { $( "#dialog-form" ).dialog( "open" ); }); $( "#dialog-form" ).dialog({ autoOpen: false, height: 120, width: 200, modal: true, buttons: { "Pievienot": function() { $( "#competition" ).append( "<option selected='selected' value='" + $( "#new_option" ).val() + "'>" + $( "#new_option" ).val() + "</option>" ); $( this ).dialog( "close" ); }, Quote Link to comment Share on other sites More sharing options...
briedis Posted January 7, 2012 Report Share Posted January 7, 2012 Ja vairāki, tad vajag likt klasi, nevis ID, jo ID ir jābūt unikāla. Lai iterētu caur objektiem, izmanto $.each Quote Link to comment Share on other sites More sharing options...
aika Posted January 7, 2012 Author Report Share Posted January 7, 2012 (edited) id būs dažādi un izmantošu slice lai atšķirtu izsaucēja id no apstrādājamā id var currentId = $(this).attr('id').slice(2); galvenais jau ka nav skaidrs kā padot klasi/id uz izsaukto dialogu!! Edited January 7, 2012 by aika Quote Link to comment Share on other sites More sharing options...
aika Posted January 7, 2012 Author Report Share Posted January 7, 2012 .data() !!! nebiju pamanījis $( "#dialog-form" ).dialog( "open" ).data('id', "#competition"); :) Quote Link to comment Share on other sites More sharing options...
daGrevis Posted January 8, 2012 Report Share Posted January 8, 2012 > Lai iterētu caur objektiem, izmanto $.each Izmanto $.each() tikai tad, kad ir labs iemesls izmantot to, nevis for (). 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.