Jump to content
php.lv forumi
Sign in to follow this  
aika

Palīdziet nounificēt

Recommended Posts

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" );

	},

Share this post


Link to post
Share on other sites

Ja vairāki, tad vajag likt klasi, nevis ID, jo ID ir jābūt unikāla.

 

Lai iterētu caur objektiem, izmanto $.each

Share this post


Link to post
Share on other sites

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 by aika

Share this post


Link to post
Share on other sites

.data() !!!

nebiju pamanījis

$( "#dialog-form" ).dialog( "open" ).data('id', "#competition");

:)

Share this post


Link to post
Share on other sites

> Lai iterētu caur objektiem, izmanto $.each

 

Izmanto $.each() tikai tad, kad ir labs iemesls izmantot to, nevis for ().

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...