Re: [Proto-Scripty] Confirm() happening twice on click.

2012-07-11 Thread Jason Westbrook
Honestly I'm not exactly sure

there is a possibility that the observe method was calling confirmDelete
instead of just tagging it as the event handler

Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com



On Wed, Jul 11, 2012 at 12:06 PM, thinsoldier
wrote:

> Thanks for all your help. Thing thing has been buggin me for a very long!
>
> Could you explain what exactly was happening with my original code that
> made the confirm fire twice?
>
>
> On Wednesday, 11 July 2012 14:13:13 UTC-4, Jason wrote:
>>
>>
>>
>> I don't see any problems with the HTML elements
>>
>> and to answer your question the observe method identifies the function as
>> the "handler" and passes the event object to the handler
>>
>>
>> and you can get the javascript to one line if you want
>>
>> $$("td a.delete").invoke("observe","**click",confirmDelete);
>>
>>
>> Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com
>>
>>
>>
>> On Wed, Jul 11, 2012 at 10:40 AM, thinsoldier <
>> thinsold...@thinsoldier.com> wrote:
>>
>>>
>>>
>>> On Wednesday, 11 July 2012 12:37:45 UTC-4, Jason wrote:


 can you either post the HTML that you are using or post the url where
 it is located publicly?


>>> Here is the html:
>>>
>>> 
>>> 
>>> 
>>> Saved
>>> Name
>>> Rename
>>> Delete
>>> Switch Format
>>> Browse
>>> 
>>> 
>>> 
>>> 
>>>   
>>> 11 Nov, 2009
>>>   
>>>   
>>> >> title="Access RSS Feed">  Sale
>>> less than x 250 thousand 
>>>   
>>>   
>>> Rename
>>>   
>>>   
>>> >> title="Cannot undo.">>> alt="delete">
>>>   
>>>   
>>> 
>>>>> src="/images/icons/arrow_**right_16.png"> >> src="/images/icons/email_32.**png">
>>> 
>>>   
>>>   
>>> >> src="/images/icons/search_32.**png" alt="view results">
>>>   
>>> 
>>> 
>>>   
>>> 25 Jun, 2012
>>>   
>>>   
>>> >> title="Access RSS Feed">  All the
>>> -plexes in NP 
>>>   
>>>   
>>> Rename
>>>   
>>>   
>>> >> title="Cannot undo.">>> alt="delete">
>>>   
>>>   
>>> 
>>>  >> src="/images/icons/arrow_**right_16.png"> >> src="/images/icons/email_32.**png">
>>>
>>>   
>>>   
>>> >> src="/images/icons/search_32.**png" alt="view results">
>>>   
>>> 
>>> 
>>> 
>>>
>>>
>>>

 you can simplify your javascript this way


 $$('td a.delete').each(function(s){
 s.observe('click', **confirmDele**te);
   } );

>>>
>>> But wouldn't the confirmDelete function need to be given the click event
>>> so it knows which click Event object to event.*stop*() ?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Prototype & script.aculo.us" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/prototype-scriptaculous/-/**u_tbuSa5zEcJ
>>> .
>>>
>>> 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
>>> .
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/prototype-scriptaculous/-/wwHOXznXcpYJ.
>
> 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.
>

-- 
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.



Re: [Proto-Scripty] Confirm() happening twice on click.

2012-07-11 Thread thinsoldier
Thanks for all your help. Thing thing has been buggin me for a very long!

Could you explain what exactly was happening with my original code that 
made the confirm fire twice?

On Wednesday, 11 July 2012 14:13:13 UTC-4, Jason wrote:
>
>
>
> I don't see any problems with the HTML elements
>
> and to answer your question the observe method identifies the function as 
> the "handler" and passes the event object to the handler
>
>
> and you can get the javascript to one line if you want
>
> $$("td a.delete").invoke("observe","click",confirmDelete);
>
>
> Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com 
>
>
>
> On Wed, Jul 11, 2012 at 10:40 AM, thinsoldier  > wrote:
>
>>
>>
>> On Wednesday, 11 July 2012 12:37:45 UTC-4, Jason wrote:
>>>
>>>
>>> can you either post the HTML that you are using or post the url where it 
>>> is located publicly?
>>>
>>>
>> Here is the html:
>>
>> 
>> 
>> 
>> Saved
>> Name
>> Rename
>> Delete
>> Switch Format
>> Browse
>> 
>> 
>> 
>> 
>>   
>> 11 Nov, 2009
>>   
>>   
>> > title="Access RSS Feed">  Sale less 
>> than x 250 thousand 
>>   
>>   
>> > href="user.php?cmd=savedSearchRenameForm&id=39">Rename
>>   
>>   
>> > title="Cannot undo.">
>>   
>>   
>> > href="user.php?cmd=savedSearchSwitchFormat&id=39" title="Receive this 
>> by e-mail instead.">
>>> src="/images/icons/arrow_right_16.png"> > src="/images/icons/email_32.png">
>> 
>>   
>>   
>> > href="search.php?cmd=search&formcat=residential&searchType=BUYSEARCH&searchOnPriceField=price&island=252&maxprice=25">>  
>> src="/images/icons/search_32.png" alt="view results">
>>   
>> 
>> 
>>   
>> 25 Jun, 2012
>>   
>>   
>> > title="Access RSS Feed">  All the 
>> -plexes in NP 
>>   
>>   
>> > href="user.php?cmd=savedSearchRenameForm&id=77">Rename
>>   
>>   
>> > title="Cannot undo.">
>>   
>>   
>> > href="user.php?cmd=savedSearchSwitchFormat&id=77" title="Receive this 
>> by e-mail instead.">
>>  > src="/images/icons/arrow_right_16.png"> > src="/images/icons/email_32.png">
>>
>>   
>>   
>> > href="search.php?cmd=search&formcat=residential&searchType=BUYSEARCH&searchOnPriceField=price&island=410&property_type%5B0%5D=655&property_type%5B1%5D=656&property_type%5B2%5D=657&property_type%5B3%5D=695">>  
>> src="/images/icons/search_32.png" alt="view results">
>>   
>> 
>> 
>> 
>>
>>  
>>
>>>
>>> you can simplify your javascript this way
>>>
>>>
>>> $$('td a.delete').each(function(s){
>>> s.observe('click', **confirmDelete);
>>>   } );
>>>
>>
>> But wouldn't the confirmDelete function need to be given the click event 
>> so it knows which click Event object to event.*stop*() ?
>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Prototype & script.aculo.us" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/prototype-scriptaculous/-/u_tbuSa5zEcJ.
>>
>> 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.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/wwHOXznXcpYJ.
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.



Re: [Proto-Scripty] Confirm() happening twice on click.

2012-07-11 Thread Jason Westbrook
I don't see any problems with the HTML elements

and to answer your question the observe method identifies the function as
the "handler" and passes the event object to the handler


and you can get the javascript to one line if you want

$$("td a.delete").invoke("observe","click",confirmDelete);


Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com



On Wed, Jul 11, 2012 at 10:40 AM, thinsoldier
wrote:

>
>
> On Wednesday, 11 July 2012 12:37:45 UTC-4, Jason wrote:
>>
>>
>> can you either post the HTML that you are using or post the url where it
>> is located publicly?
>>
>>
> Here is the html:
>
> 
> 
> 
> Saved
> Name
> Rename
> Delete
> Switch Format
> Browse
> 
> 
> 
> 
>   
> 11 Nov, 2009
>   
>   
>  title="Access RSS Feed">  Sale less
> than x 250 thousand 
>   
>   
>  href="user.php?cmd=savedSearchRenameForm&id=39">Rename
>   
>   
>  title="Cannot undo.">
>   
>   
>  href="user.php?cmd=savedSearchSwitchFormat&id=39" title="Receive this
> by e-mail instead.">
> src="/images/icons/arrow_right_16.png">  src="/images/icons/email_32.png">
> 
>   
>   
>  href="search.php?cmd=search&formcat=residential&searchType=BUYSEARCH&searchOnPriceField=price&island=252&maxprice=25"> src="/images/icons/search_32.png" alt="view results">
>   
> 
> 
>   
> 25 Jun, 2012
>   
>   
>  title="Access RSS Feed">  All the
> -plexes in NP 
>   
>   
>  href="user.php?cmd=savedSearchRenameForm&id=77">Rename
>   
>   
>  title="Cannot undo.">
>   
>   
>  href="user.php?cmd=savedSearchSwitchFormat&id=77" title="Receive this
> by e-mail instead.">
>   src="/images/icons/arrow_right_16.png">  src="/images/icons/email_32.png">
>
>   
>   
>  href="search.php?cmd=search&formcat=residential&searchType=BUYSEARCH&searchOnPriceField=price&island=410&property_type%5B0%5D=655&property_type%5B1%5D=656&property_type%5B2%5D=657&property_type%5B3%5D=695"> src="/images/icons/search_32.png" alt="view results">
>   
> 
> 
> 
>
>
>
>>
>> you can simplify your javascript this way
>>
>>
>> $$('td a.delete').each(function(s){
>> s.observe('click', **confirmDelete);
>>   } );
>>
>
> But wouldn't the confirmDelete function need to be given the click event
> so it knows which click Event object to event.*stop*() ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/prototype-scriptaculous/-/u_tbuSa5zEcJ.
>
> 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.
>

-- 
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.



Re: [Proto-Scripty] Confirm() happening twice on click.

2012-07-11 Thread thinsoldier


On Wednesday, 11 July 2012 12:37:45 UTC-4, Jason wrote:
>
>
> can you either post the HTML that you are using or post the url where it 
> is located publicly?
>
>
Here is the html:




Saved
Name
Rename
Delete
Switch Format
Browse




  
11 Nov, 2009
  
  
  Sale less 
than x 250 thousand 
  
  
Rename
  
  

  
  



  
  

  


  
25 Jun, 2012
  
  
  All the 
-plexes in NP 
  
  
Rename
  
  

  
  

  
   
  
  

  




 

>
> you can simplify your javascript this way
>
>
> $$('td a.delete').each(function(s){
> s.observe('click', confirmDelete);
>   } );
>

But wouldn't the confirmDelete function need to be given the click event so 
it knows which click Event object to event.*stop*() ?

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/u_tbuSa5zEcJ.
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.



Re: [Proto-Scripty] Confirm() happening twice on click.

2012-07-11 Thread thinsoldier

>
> you can simplify your javascript this way
>
>
> $$('td a.delete').each(function(s){
> s.observe('click', confirmDelete);
>   } );
>

Ok that worked. But now I'm very confused.

For years I've been intentionally giving anonymous functions to observers 
because it seemed the work horse functions had no knowledge of the event 
details unless it was passed directly to them via the anon function. I'm 
now totally confused. 

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/f-R60o2ysCUJ.
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.



Re: [Proto-Scripty] Confirm() happening twice on click.

2012-07-11 Thread Jason Westbrook
can you either post the HTML that you are using or post the url where it is
located publicly?


you can simplify your javascript this way


$$('td a.delete').each(function(s){
s.observe('click', confirmDelete);
  } );


Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com



On Wed, Jul 11, 2012 at 9:26 AM, thinsoldier  wrote:

> Hello.
>
> I have a page that lists records and each row has a link that goes to a
> page which deletes the associated record.
>
> But before the browser navigates to that page I stop it by asking the user
> if they really want to delete the item.
>
> If they click cancel the browser goes nowhere.
> If they click OK the browser navigates to the php file that deletes the
> record.
>
> My problem is that after the confirm() UI appears and is clicked, it
> appears AGAIN, then when I click again does the expected behaviour occur.
>
> What is causing that in this code?
>
> document.observe("dom:loaded", function() {
>   // attach to all delete links in the table
>   var dels = $$('td a.delete');
>   dels.each(function(s){
> s.observe('click', function(event){ confirmDelete(event); }  );
>   } )
> });
>
>
> function confirmDelete(event)
> {
> var ask = confirm('Are you sure you want to delete this entry?');
>
> if(ask){ xfoo = 'follow link - delete it'; }
> else{ event.stop();  xfoo =' do nothing - stop event ';  }
> }
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/prototype-scriptaculous/-/qwdMPG_i8WMJ.
> 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.
>

-- 
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] Confirm() happening twice on click.

2012-07-11 Thread thinsoldier
Hello.

I have a page that lists records and each row has a link that goes to a 
page which deletes the associated record.

But before the browser navigates to that page I stop it by asking the user 
if they really want to delete the item.

If they click cancel the browser goes nowhere.
If they click OK the browser navigates to the php file that deletes the 
record.

My problem is that after the confirm() UI appears and is clicked, it 
appears AGAIN, then when I click again does the expected behaviour occur.

What is causing that in this code?

document.observe("dom:loaded", function() {
  // attach to all delete links in the table
  var dels = $$('td a.delete');
  dels.each(function(s){
s.observe('click', function(event){ confirmDelete(event); }  );
  } )
});


function confirmDelete(event)
{
var ask = confirm('Are you sure you want to delete this entry?');

if(ask){ xfoo = 'follow link - delete it'; }
else{ event.stop();  xfoo =' do nothing - stop event ';  }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/qwdMPG_i8WMJ.
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.