[Proto-Scripty] A better way to check for an element.

2009-09-18 Thread Luisgo

Hey all,

I was wondering if you can suggest a better way of achieving what this
snippet does. I do it often enough that it starts bloating my code and
frankly just gets annoying to type.

   var some_button = $('some-button')
   if ( some_button ) {
 some_button.observe(click,function(event){
   event.stop();
   form_object.save();
 });
   }

I can compress it a bit by doing this:

   if ( some_button = $('some-button') ) {
 some_button.observe(click,function(event){
   event.stop();
   form_object.save();
 });
   }

But that's little consolation.

In an ideal world I would want to do something close to:

   $('some-button').observe(click,function(){
 form_object.save();
   }, false );

Note: that false parameter would replace event.stop() which happens
often enough. Defaults to true.

Or even like (I know it looks like JQuery):

   $('some-button').click(function(){
 form_object.save();
   },false);

Any ideas/suggestions?

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 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Need clarification or guidance regarding arrays/hashes

2009-06-10 Thread Luisgo

I've been a long time user of prototype and feel very comfortable in
most areas but this keeps coming up and I find it very annoying.

I have a hash that, as the code executes is filled with numeric ID's
as hash variable names. I basically need it to end up sort of like
this:

{
'4567':{},
'9546':{},
'6497':{},
...
}

The problem is the IDs are passed as strings but casted as integers
when I do:

myHash.set( idPassedInVariable, {} );

This causes the hash to be filled by undefined items where the
missing numeric IDs would be. In the example above I would end up
with 0 to 4566 being undefined and every space in between the rest of
the keys.

Am I doing something wrong? Isn't there a way to make set pass the
string or is javascript simply going to force it to be a number?

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 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Problems with the down() function and the new Browser Generation

2009-06-10 Thread Luisgo

Tears of joy!!!

Thank you for this. I have been changing a ton of code thinking the
problem was in prototype and it was simply that I was using IDs just
like you. I added a simple freaking character to the IDs and presto!

I had already filed a ticket for this here:
https://prototype.lighthouseapp.com/projects/8886/tickets/704-downselect-failing-in-ie8
(now closed)

Thanks again!

On Jun 8, 11:17 am, Posseidon possei...@aon.at wrote:
 Hi guys

 Thank you for the answer!
 The problem was self made! It seems that the new Browser Generation is
 more with the Standards. I had as ID attribute only a number. And this
 is since HTML 4 wrong.
 an ID Attribute must not start with a number or must not be a number
 only!

 td id=456 -- was wrong
 now i fixed it like td id=gb_456 and i get out the id with id.split
 ('_')[1]

 thx for all answers...

 Best regards

 Posseidon

 On Jun 8, 12:34 pm, david david.brill...@gmail.com wrote:



  Hi Posseidon,

  The actual prototype is compatible with safari =3, opera =9 and
  IE=8.
  I think you should open a ticket to lighthouse. the url 
  ishttps://prototype.lighthouseapp.com/projects/8886-prototype

  The code is very difficult to test, perhaps if we'll have an XHR input
  to test with ??

  --
  david

  On 7 juin, 13:57, Posseidon possei...@aon.at wrote:

   Hi guys...

   I have some Problems in all modern Browsers (IE8, Safari4, Opera10)
   using the Element.down() function. I'm building with a Template a list
   of div containers and in those containers there is some text and two
   buttons. The buttons come when the User has the right rights to click
   on them. After the creation of this containers i look with Element.down
   ('img.buttonDelete') if there is the image inserted or not. But when i
   use this function the Browser stops the insertion. It looks like there
   is an error but no browser fires an error at all. here is some code..

   var gbEtmpl = new Template('div id=#{eid} style=padding-bottom:
   5px;' +
                                'div style=text-align:left; width:100%;
   height:93px; background-image:url(./pics/site/main/gbback_02.png);
   background-repeat:no-repeat;'+
                                  'div style=padding-top:55px; padding-
   left:20px; font-family:Arial Black, Verdana; color:#00; font-size:
   13px; font-weight:500;'+
                                    '#{hl}'+
                                  '/div'+
                                '/div'+
                                'div style=width:100%; text-align:left;
   background-image:url(./pics/site/main/gbback_03.png); background-
   repeat:repeat-y;'+
                                  'div style=min-height:100px; padding-
   top:10px; padding-left:20px; padding-right:30px;'+
                                    '#{msg}'+
                                  '/div'+
                                '/div'+
                                'div style=background-image:url(./pics/
   site/main/gbback_05.png); background-repeat:no-repeat;'+
                                  'div class=clearfix style=height:
   43px; padding-top:15px; margin-left:15px;'+
                                    'div style=line-height:18px;
   float:left; width:49%; text-align:left;'+
                                      '#{ed}nbsp;nbsp;#{ee}nbsp;nbsp;#
   {date} #{time} #{uname}'+
                                    '/div'+
                                    'div style=line-height:18px;
   float:left; width:50%; text-align:right;'+
                                      'div style=padding-right:15px;'
   +
                                        '#{em} #{hp} #{icq} #{aim} #{yim}
   #{msn} #{xf}'+
                                      '/div' +
                                    '/div'+
                                  '/div'+
                                '/div'+
                              '/div');

   function showEntrys( XHR )
   {
     var e, i, imgObject;
     edata = XHR.entrys;
     $('entrys').childElements().invoke('remove');
     for( i = 0; i  edata.length; i++ ) {
       e = edata[i];
       $('entrys').insert( gbEtmpl.evaluate({ eid:e.eid, hl:e.hl,
   date:e.date, time:e.time, uname:e.uname, msg:e.msg, icq:e.icq,
   aim:e.aim, yim:e.yim,
                                              msn:e.msn, xf:e.xf,
   hp:e.hp, em:e.em, ed:e.ed, ee:e.ee }) );
       alert( e.eid );
       if( $( e.eid ).down('img.gbEditButton') ) alert('isda');
       if( $( e.eid ).down('img.gbEditButton') != undefined ) $
   ( e.eid ).down('img.gbEditButton').onclick = showEditEntry;
       if( $( e.eid ).down('img.gbDeleteButton') != undefined ) $
   ( e.eid ).down('img.gbDeleteButton').onclick = msgBoxDeleteEntry;
     }

   }

   I have two alerts in there to show you how far the browser comes with
   parsing... In Firefox there is no Problem both alerts are coming and
   the insertion goes till the end... this code worked one year and now
   with the new Browser generation something is going wrong...