[Proto-Scripty] Re: How to insert element with value taken from attribute of parent ?

2010-08-30 Thread elivol
thank you a very much for a detailed answer ! it works fine.

On Aug 30, 12:31 am, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

 You don't want #invoke, you want #each:

 $$('div.item_content').each(function(div) {
     div.insert({
         bottom: 'input type=checkbox class=compare_itm
 onclick=Itm.Click(\''+
         div.readAttribute('sale_num') +'\') /'
     });

 });

 http://api.prototypejs.org/language/enumerable/prototype/each/

 Also note I've used #readAttribute (Prototype) rather than
 getAttribute (DOM), as it handles some issues for you:

 http://api.prototypejs.org/dom/element/readattribute/

 Off-topic: That HTML is invalid, because you're defining an attribute
 (`sale_num`) that doesn't exist in the standard. It works, it's just
 invalid. As of HTML5, there's a valid way to have custom attributes:
 Use a data- prefix. So `data-sale_num` would be a valid attribute
 name. FWIW.

 HTH,
 --
 T.J. Crowder
 Independent Software Consultant
 tj / crowder software / comwww.crowdersoftware.com

 On Aug 29, 8:47 am, elivol eli...@gmail.com wrote:

  Hello
  Unfortunately  it doesn't work:
  $$('div.item_content').invoke('insert', {bottom: 'input
  type=checkbox class=compare_itm onclick=Itm.Click(\''+
  this.getAttribute('sale_num') +'\') /' });

  The script fails if I put this.getAttribute('sale_num')

  On Aug 27, 6:55 pm, Walter Lee Davis wa...@wdstudio.com wrote:

   You could get the value inside your iterator by looking at:

   this.getAttribute('sale_num')

   Inside of an invoke iterator, 'this' is set to the current object of  
   affection.

   Don't forget to give your generated checkbox an ID or name or  
   something else based on this value you get, so your checkboxes will  
   tell a story to your compare script!

   Walter

   On Aug 27, 2010, at 9:01 AM, elivol wrote:

Hello.
I have this HTML code:
div class=item_content sale_num=12345some stuff/div
div class=item_content sale_num=123456some stuff/div

I need to insert a checkbox into div item_content with value of
sale_num attribute.
I'm trying to do it with:
$$('div.item_content').invoke('insert', {bottom: 'input
type=checkbox class=compare_itm value= /' });

but i have no idea how to continue.
thanks in advance.

--
You received this message because you are subscribed to the Google  
Groups Prototype  script.aculo.us group.
To post to this group, send email to 
prototype-scriptaculous@googlegroups.com
.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
.
For more options, visit this group 
athttp://groups.google.com/group/prototype-scriptaculous?hl=en
.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: How to insert element with value taken from attribute of parent ?

2010-08-29 Thread elivol
Hello
Unfortunately  it doesn't work:
$$('div.item_content').invoke('insert', {bottom: 'input
type=checkbox class=compare_itm onclick=Itm.Click(\''+
this.getAttribute('sale_num') +'\') /' });

The script fails if I put this.getAttribute('sale_num')



On Aug 27, 6:55 pm, Walter Lee Davis wa...@wdstudio.com wrote:
 You could get the value inside your iterator by looking at:

 this.getAttribute('sale_num')

 Inside of an invoke iterator, 'this' is set to the current object of  
 affection.

 Don't forget to give your generated checkbox an ID or name or  
 something else based on this value you get, so your checkboxes will  
 tell a story to your compare script!

 Walter

 On Aug 27, 2010, at 9:01 AM, elivol wrote:

  Hello.
  I have this HTML code:
  div class=item_content sale_num=12345some stuff/div
  div class=item_content sale_num=123456some stuff/div

  I need to insert a checkbox into div item_content with value of
  sale_num attribute.
  I'm trying to do it with:
  $$('div.item_content').invoke('insert', {bottom: 'input
  type=checkbox class=compare_itm value= /' });

  but i have no idea how to continue.
  thanks in advance.

  --
  You received this message because you are subscribed to the Google  
  Groups Prototype  script.aculo.us group.
  To post to this group, send email to 
  prototype-scriptaculous@googlegroups.com
  .
  To unsubscribe from this group, send email to 
  prototype-scriptaculous+unsubscr...@googlegroups.com
  .
  For more options, visit this group 
  athttp://groups.google.com/group/prototype-scriptaculous?hl=en
  .

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: How to insert element with value taken from attribute of parent ?

2010-08-29 Thread T.J. Crowder
Hi,

You don't want #invoke, you want #each:

$$('div.item_content').each(function(div) {
div.insert({
bottom: 'input type=checkbox class=compare_itm
onclick=Itm.Click(\''+
div.readAttribute('sale_num') +'\') /'
});
});

http://api.prototypejs.org/language/enumerable/prototype/each/

Also note I've used #readAttribute (Prototype) rather than
getAttribute (DOM), as it handles some issues for you:

http://api.prototypejs.org/dom/element/readattribute/

Off-topic: That HTML is invalid, because you're defining an attribute
(`sale_num`) that doesn't exist in the standard. It works, it's just
invalid. As of HTML5, there's a valid way to have custom attributes:
Use a data- prefix. So `data-sale_num` would be a valid attribute
name. FWIW.

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Aug 29, 8:47 am, elivol eli...@gmail.com wrote:
 Hello
 Unfortunately  it doesn't work:
 $$('div.item_content').invoke('insert', {bottom: 'input
 type=checkbox class=compare_itm onclick=Itm.Click(\''+
 this.getAttribute('sale_num') +'\') /' });

 The script fails if I put this.getAttribute('sale_num')

 On Aug 27, 6:55 pm, Walter Lee Davis wa...@wdstudio.com wrote:



  You could get the value inside your iterator by looking at:

  this.getAttribute('sale_num')

  Inside of an invoke iterator, 'this' is set to the current object of  
  affection.

  Don't forget to give your generated checkbox an ID or name or  
  something else based on this value you get, so your checkboxes will  
  tell a story to your compare script!

  Walter

  On Aug 27, 2010, at 9:01 AM, elivol wrote:

   Hello.
   I have this HTML code:
   div class=item_content sale_num=12345some stuff/div
   div class=item_content sale_num=123456some stuff/div

   I need to insert a checkbox into div item_content with value of
   sale_num attribute.
   I'm trying to do it with:
   $$('div.item_content').invoke('insert', {bottom: 'input
   type=checkbox class=compare_itm value= /' });

   but i have no idea how to continue.
   thanks in advance.

   --
   You received this message because you are subscribed to the Google  
   Groups Prototype  script.aculo.us group.
   To post to this group, send email to 
   prototype-scriptaculous@googlegroups.com
   .
   To unsubscribe from this group, send email to 
   prototype-scriptaculous+unsubscr...@googlegroups.com
   .
   For more options, visit this group 
   athttp://groups.google.com/group/prototype-scriptaculous?hl=en
   .

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.