[Proto-Scripty] Re: limit number of éléments in a dropzone

2008-10-28 Thread bronson

No way to get a hand ?

On 26 oct, 19:10, bronson [EMAIL PROTECTED] wrote:
 Hi every body,

 I want to freeze the drag from the dragzone when the dropzone's
 elements'length reach, for example, 3 elements and i wih to trigger an
 alert message, advising the visitor that the dropzone can't exceed 3
 elements.

 I can't figure out how?

 my code
   Sortable.create(
     liste_1,
     {
       tag:div,
       dropOnEmpty: true,
       containment:[liste_1,liste_2],
       only:lineitem
     }
 );

   Sortable.create(
     liste_2,{tag:div,dropOnEmpty: true,
                                 containment: [liste_1,liste_2], 
 only:lineitem,

 });

 Many thanks for your help.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Problem with prototype.js

2008-10-28 Thread PAM

hi all,


i m working with prototype.js 1.6 and drag n drop

when i m using this code :new Element.insert(div, {top:content});

i m passing into this method :

Element._getContentFromAnonymousElement = function(tagName, html) {
  var div = new Element('div'), t =
Element._insertionTranslations.tags[tagName];
  if (t) {
div.innerHTML = t[0] + html + t[1];
t[2].times(function() { div = div.firstChild });
  } else div.innerHTML = html;
  return $A(div.childNodes);
};

but   var div = new Element('div') is not working... my javascript
stop here, but if i replace this line by
var div = document.createElement(div);

all is working fine..

someone can help me to find why first solution is not working?

thanks by 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Problem with prototype.js

2008-10-28 Thread PAM

hi

thanks for your response

more precisions:

i m using rico (2.0rc2) with protoype.js

and this code : http://pastie.org/302127
i don t write this code, just use it and try to understand it ;) (see
http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=65)

all working fine with prototype.js (1.4) but when i m upgrading to
prototype.js 1.6

the line 6 (http://pastie.org/302127)  is not working as i say in my
previous message because in prototype.js (1.6)
at line 2501  (var div = new Element('div'), t =
Element._insertionTranslations.tags[tagName];)

new Element('div'), not working...but i don t know why

if i replace new Element('div') by document.createElement(div);

all working fine.



On 28 oct, 10:58, T.J. Crowder [EMAIL PROTECTED] wrote:
 Hi,

  when i m using this code :new Element.insert(div, {top:content});

 Two things come to mind:

 1. What is assigned to div?  It's a variable in that
 snippet...what's in it?

 2. That syntax looks problematic to me.  new Element.insert(div,
 {top:content}); tries to use the function Element.insert as a
 constructor.

 Did you mean (new Element('div')).insert({top: content});?  I made
 two changes there:  I put 'div' in quotes and used Element as the
 constructor.

 If the above doesn't help, try creating a small self-contained example
 that demonstrates the problem and posting it to Pastie[1].  You might
 figure it out by doing that, but if not it gives us a complete example
 to look at.

 [1]http://pastie.org

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com

 On Oct 28, 9:43 am, PAM [EMAIL PROTECTED] wrote:

  hi all,

  i m working with prototype.js 1.6 and drag n drop

  when i m using this code :new Element.insert(div, {top:content});

  i m passing into this method :

  Element._getContentFromAnonymousElement = function(tagName, html) {
    var div = new Element('div'), t =
  Element._insertionTranslations.tags[tagName];
    if (t) {
      div.innerHTML = t[0] + html + t[1];
      t[2].times(function() { div = div.firstChild });
    } else div.innerHTML = html;
    return $A(div.childNodes);

  };

  but   var div = new Element('div') is not working... my javascript
  stop here, but if i replace this line by
  var div = document.createElement(div);

  all is working fine..

  someone can help me to find why first solution is not working?

  thanks by 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Problem with the sortable system

2008-10-28 Thread Benjamin

Hi guys,
I'm having some troubles with the sortable system.
Here's a simple example of my code :

a href=# onclick=reload();Reload/a
ul id=my_ul
li id=li_1test 1/li
li id=li_2test 2/li
/ul

script type=text/javascript
Sortable.create('my_ul', {
onChange:function(){
alert(Sortable.sequence('my_ul').join(''));
}
});
/script

When I load the page, there's no problem, I can reorder the list. But
when I'm clicking on the Reload link, there's no way I can move any
of the new li elements.
The reload(); function is quite basic:
function reload()
{
writediv('li id=li_3test 3/lili id=li_4test 4/li',
'my_ul');
}

So I guess the Sortable function only work if I'm not editing the ul
list. Is there any tips I could use to do it?

Thanks guys.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Autocompleter Updater

2008-10-28 Thread James Hoddinott

I have an input element with id 'searchtickets' linked to
Autocompleter so that potential search results are returned as the
user types characters in. Updater is then called to update a div
element with id 'dmain' based on that search result. So far I have the
following javascript:

Event.observe(window,'load',function() {
  new 
Ajax.Autocompleter('searchtickets','searchticketres','data/searchtickets.php',{minChars:3});
  Event.observe('searchtickets','change',function() {
new Ajax.Updater('dmain','data/foo.php',{
  parameters:$('searchtickets').serialize()
});
  });
});


'data/foo.php' simply prints out the value of the POSTed parameters
(for testing purposes). The HTML, for completeness is:

input type='text' id='searchtickets' name='t' size='10' /
div id='searchticketres'/div
div id='dmain'/div

If I start typing in M747 into my input I correctly get some
matches returned. If I select one, say M747100, the input
correctly updates with this but the value passed to Updater seems to
be M747 as this is what 'data/foo.php' returns.

Do I need to use defer() here? I did try adding
$('searchtickets').defer(); just before calling Updater but that
didn't seem to have any effect.

-- 
James Hoddinott

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Problem with the sortable system

2008-10-28 Thread Benjamin


I tried replacing the reload() function by :
function reload()
{
var ul= $('my_ul');
ul.update('li id=li_3test 3/lili id=li_4test 4/li');
}

without any success.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Problem with the sortable system

2008-10-28 Thread Benjamin

Well I also tried it earlier, but I tried again and it's not working :

function reload()
{
text = file('ajax.php?action=reload');
if (text != 0)
writediv(texte, 'my_ul');
}


and the ajax.php file :

if ($_GET['action'] == 'test')
{
echo 'li id=li_3test 3/lili id=li_4test 4/li';
echo 'script type=text/javascript';
echo Sortable.create('my_ul', {
onChange:function(){
alert(Sortable.sequence('my_ul').join(''));
}
});;
echo '/script';
}


any other guesses?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Problem with the sortable system

2008-10-28 Thread T.J. Crowder

Hi,

What does writediv do?  Does it eval scripts?  If not...

Try putting together a complete, but very small, example showing the
problem and posting it to Pastie[1].  You'll probably figure out the
problem in the process of doing that.  If not, it gives people
something to look at.  I'd be very surprised if it's not as simple as
just recreating the Sortable, you just have to be sure the code doing
it gets executed.  Ajax.Updater[2] or Element.update[3] might help.

[1] http://pastie.org
[2] http://prototypejs.org/api/ajax/updater
[3] http://prototypejs.org/api/element/update

FWIW,
--
T.J. Crowder
tj / crowder software / com

On Oct 28, 1:57 pm, Benjamin [EMAIL PROTECTED] wrote:
 Well I also tried it earlier, but I tried again and it's not working :

 function reload()
 {
         text = file('ajax.php?action=reload');
         if (text != 0)
                 writediv(texte, 'my_ul');

 }

 and the ajax.php file :

 if ($_GET['action'] == 'test')
 {
         echo 'li id=li_3test 3/lili id=li_4test 4/li';
         echo 'script type=text/javascript';
         echo Sortable.create('my_ul', {
                         onChange:function(){
                         alert(Sortable.sequence('my_ul').join(''));
                 }
                 });;
         echo '/script';

 }

 any other guesses?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Problem with the sortable system

2008-10-28 Thread T.J. Crowder

LOL Glad I could help.

-- T.J.

On Oct 28, 3:24 pm, Benjamin [EMAIL PROTECTED] wrote:
 Damn you T.J. Crowder I love you ! You solved the problem I had for
 like a week !

 Here's a simple example :
 head
 titleSortable list/title
 script src=lib/prototype.js type=text/javascript/script
 script src=src/scriptaculous.js type=text/javascript/script
 script type=text/javascript
 function test()
 {
         $('my_ul').update('li id=li_3li 3/lili id=li_4li 4/li');
         Sortable.create('my_ul', {
         onChange:function(){
                 alert(Sortable.sequence('my_ul').join(''));
         }
         });}

 /script
 /head
 body
 ul id=my_ul
         li id=li_1li 1/li
     li id=li_2li 2/li
     script type=text/javascript
         Sortable.create('my_ul', {
         onChange:function(){
                 alert(Sortable.sequence('my_ul').join(''));
         }
         });
     /script
 /ul
 a href=# onclick=test()Change it!/a
 /body
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: trouble with delayedobserver

2008-10-28 Thread ecb

I need it once.  I've done some testing on this.  Everything in the
callback function is called twice.  In fact, the callback function is
initialized twice when the page is loaded, which I confirmed by
putting an alert in the initialize block of the class definition (in
controls.js).


On Oct 23, 10:05 am, kangax [EMAIL PROTECTED] wrote:
 On Oct 21, 2:30 pm, ecb [EMAIL PROTECTED] wrote:

  Here's the code.  It's simple enough:

  blockquote

  new Form.Element.DelayedObserver( 'inputfield', .50, function()
  { simplefunction(); })

  function simplefunction() { alert(here I am); }

  /blockquote

  The problem I'm having is that simplefunction is being called twice.

 How many times do you need it to be called?



  Best

  Adam

 --
 kangax
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: php-like variable variables in Prototype syntax?

2008-10-28 Thread Walter Lee Davis


On Oct 27, 2008, at 10:42 PM, kangax wrote:




 On Oct 27, 1:20 pm, Walter Lee Davis [EMAIL PROTECTED] wrote:
 Is there a more Prototype way to construct a variable key within
 JavaScript, similar to what you can do in PHP? For example, in  
 PHP, if
 I had the string 'title' assigned to the variable $class, and I  
 wanted
 the current value of the variable $titles, I could construct a
 'variable variable', which would point back to $titles:

 $titles = Array('Gone with the Wind','The Wind in the Willows','Break
 like the Wind');

 $class = 'title'; //plain string

 $key = $class + 's'; //concatenate for poor man's pluralize

 echo ($$key == $titles) ? true: false; // = true

 In JavaScript, Google tells me that eval() will do the same thing,  
 but
 I've heard over and over on this list that eval() is evil and to be
 avoided. Any suggestions?

 Easy:

 var titles = [ 'Gone with the Wind', 'The Wind in the Willows', 'Break
 like the Wind' ];
 var klass = 'title'; //plain string
 var key = klass + 's'; //concatenate for poor man's pluralize
 window[key] === titles; // true



I had tried window[key] before, and it didn't work, but your answer  
(and another thread on this list) reminded me that I was inside an  
anonymous function, so this[key] was the trick.

Thanks again,

Walter

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: trouble with delayedobserver

2008-10-28 Thread Walter Lee Davis

See what happens if you do this:

var simplefunction = function(){ alert('howdy!'); }

new Form.Element.DelayedObserver( 'inputfield', .50,  
simplefunction); //just the var name of the function, no parens after  
it...

I think this might be one of those issues where you mean to name a  
function instead of calling it.

Walter

On Oct 28, 2008, at 1:22 PM, ecb wrote:


 I need it once.  I've done some testing on this.  Everything in the
 callback function is called twice.  In fact, the callback function is
 initialized twice when the page is loaded, which I confirmed by
 putting an alert in the initialize block of the class definition (in
 controls.js).


 On Oct 23, 10:05 am, kangax [EMAIL PROTECTED] wrote:
 On Oct 21, 2:30 pm, ecb [EMAIL PROTECTED] wrote:

 Here's the code.  It's simple enough:

 blockquote

 new Form.Element.DelayedObserver( 'inputfield', .50, function()
 { simplefunction(); })

 function simplefunction() { alert(here I am); }

 /blockquote

 The problem I'm having is that simplefunction is being called  
 twice.

 How many times do you need it to be called?



 Best

 Adam

 --
 kangax
 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Get sub divs?

2008-10-28 Thread [EMAIL PROTECTED]

Hello,

i try many times but i i get always  undefined

when i try this

alert($(sourceid).select('entry').innerHTML);
or this
alert($(sourceid).select('RECHNUNGID').innerHTML);
or this
alert($(sourceid).select('RECHNUNGID').valu;

:(



T.J. Crowder schrieb:
 Hi Stefan,
 
 If you're just starting out with Prototype, it's well worth your time
 reading through the API docs from beginning to end.  It'll take 1-2
 hours, and it will save you far more time than that as you continue
 your work.  The API docs are here:
 http://prototypejs.org/api
 
 $() is for select elements by *ID*.  If you want to look for them
 using CSS selectors, $$() will look starting at the document level, or
 Element.select() will look within a given element.
 
 http://prototypejs.org/api/utility/dollar
 http://prototypejs.org/api/utility/dollar-dollar
 http://prototypejs.org/api/element/select
 
 HTH,
 --
 T.J. Crowder
 tj / crowder software /com
 
 On Oct 25, 10:13 pm, Stefan [EMAIL PROTECTED] wrote:
 Hello,

 how can i get the subelements?

 i have something like this

 $('mydiv').$('mydiv2').$(mydiv3').innerHTML

 that dosent work. How can i get this values ?

 and how can i irretate all divs in a parent div?

 thanks for help
  


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: php-like variable variables in Prototype syntax?

2008-10-28 Thread kangax

On Oct 28, 1:23 pm, Walter Lee Davis [EMAIL PROTECTED] wrote:
 On Oct 27, 2008, at 10:42 PM, kangax wrote:





  On Oct 27, 1:20 pm, Walter Lee Davis [EMAIL PROTECTED] wrote:
  Is there a more Prototype way to construct a variable key within
  JavaScript, similar to what you can do in PHP? For example, in  
  PHP, if
  I had the string 'title' assigned to the variable $class, and I  
  wanted
  the current value of the variable $titles, I could construct a
  'variable variable', which would point back to $titles:

  $titles = Array('Gone with the Wind','The Wind in the Willows','Break
  like the Wind');

  $class = 'title'; //plain string

  $key = $class + 's'; //concatenate for poor man's pluralize

  echo ($$key == $titles) ? true: false; // = true

  In JavaScript, Google tells me that eval() will do the same thing,  
  but
  I've heard over and over on this list that eval() is evil and to be
  avoided. Any suggestions?

  Easy:

  var titles = [ 'Gone with the Wind', 'The Wind in the Willows', 'Break
  like the Wind' ];
  var klass = 'title'; //plain string
  var key = klass + 's'; //concatenate for poor man's pluralize
  window[key] === titles; // true

 I had tried window[key] before, and it didn't work, but your answer  
 (and another thread on this list) reminded me that I was inside an  
 anonymous function, so this[key] was the trick.

Strange.
`this` should reference the same object `window` references (when
anonymous function is called) - global one. Not sure why one would
work and another wouldn't.


 Thanks again,

 Walter

--
kangax
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] get all values?

2008-10-28 Thread [EMAIL PROTECTED]

i have many divs with the same id . How can i get them all and check 
them to be = another value?

i try this:

while($('targetid').next('RECHNUNGID'))
{
alert('x');
}

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Get sub divs?

2008-10-28 Thread kangax

On Oct 28, 2:22 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hello,

 i try many times but i i get always  undefined

 when i try this

 alert($(sourceid).select('entry').innerHTML);
 or this
 alert($(sourceid).select('RECHNUNGID').innerHTML);
 or this
 alert($(sourceid).select('RECHNUNGID').valu;

 :(

`select` returns an array and array does *not* have `innerHTML`
(unless you add it explicitly to its `prototype`). Moreover, it parses
string (that you pass to it) as a selector:

alert($(sourceid).down('#RECHNUNGID').innerHTML;

[snip]

--
kangax
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: get all values?

2008-10-28 Thread [EMAIL PROTECTED]

How can i get  and irretate  a specified  class?


 On Tue, Oct 28, 2008 at 1:58 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 i have many divs with the same id .
 
 An element ID MUST be unique for the whole page. Use a class instead,
 then use the $$() method to fetch them all.
 
 -justin
 
  


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: get all values?

2008-10-28 Thread Justin Perkins

given this:
div class=foo/div
div class=foo/div
div class=foo/div
div class=foo/div

do this:

$$('div.foo').each(function(div){
  alert(div);
});

The each method is an *iterator*.
http://prototypejs.org/api/enumerable/each

-justin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Disabling Scriptaculous autocomplete

2008-10-28 Thread Perryism

This is how I fixed it.
open scriptaculous/controls.js

adding a new property, disable, to the autocompleter and set it to
false as default.

this.disable = false;

In onObserverEvent, replacing
   if(this.getToken().length=this.options.minChars)
with
   if(this.getToken().length=this.options.minChars  !
this.disable)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Storing Control.Slider objects in an array

2008-10-28 Thread jack7890

I'm trying to use a for loop to initialize a large number of
script.aculo.us sliders.  I'm finding that, for some reason, I'm
unable to store control.slider objects in an array.  For example,
consider this code:

[code]
var contextRaters_primary = new Array();

for(var i = 0; i  1; i++) {

var contextRaters_primary[i] = new Control.Slider($
('contextRaterHandle_primary1'),$('contextRaterTrack_primary1'),
{
axis:'vertical'
});
}
[/code]

I know that this for loop will only iterate once, but I'm using it to
show my point.  If I delete the [i] from the end of
contextRaters_primary[i] then it runs fine.  But when I try to run
it as I've written it, I get a missing ; before statement error.  So
for some reason it doesn't work when I try to store the slider as a
variable in an array.

Could someone PLEASE tell me why this might be?  I feel like the
answer is relatively obvious, but I'm relatively new to this and can't
figure it out.

Thanks.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Storing Control.Slider objects in an array

2008-10-28 Thread kangax

On Oct 28, 8:37 pm, jack7890 [EMAIL PROTECTED] wrote:
 I'm trying to use a for loop to initialize a large number of
 script.aculo.us sliders.  I'm finding that, for some reason, I'm
 unable to store control.slider objects in an array.  For example,
 consider this code:

 [code]
 var contextRaters_primary = new Array();

 for(var i = 0; i  1; i++) {

 var contextRaters_primary[i] = new Control.Slider($
 ('contextRaterHandle_primary1'),$('contextRaterTrack_primary1'),
                 {
                 axis:'vertical'
                 });}

 [/code]

 I know that this for loop will only iterate once, but I'm using it to
 show my point.  If I delete the [i] from the end of
 contextRaters_primary[i] then it runs fine.  But when I try to run
 it as I've written it, I get a missing ; before statement error.  So
 for some reason it doesn't work when I try to store the slider as a
 variable in an array.

 Could someone PLEASE tell me why this might be?  I feel like the
 answer is relatively obvious, but I'm relatively new to this and can't
 figure it out.

`[` and `]` can not be part of Identifier. In other words, by
prepending `var` you try to declare a variable and that variable's
name is syntactically wrong : )

Just omit `var`:
...
contextRaters_primary[i] = ...
...


 Thanks.

--
kangax
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] $$() and Element.observe() question

2008-10-28 Thread kimbaudi

Hi, I am having trouble with using Element.observe() with $$(). If I
have an element with id=id, I can do this:

$('id').observe('click', function() {alert('clicked');});

However, if I have elements with class=class, I can't do this:

$$('.class').observe('click', function() {alert('clicked');});

I know that $$() returns a document-order array of extended DOM
elements, but I have no idea how to use Element.observe() on the array
returned by $$().  Any help will be greatly appreciated.

- Paul
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---