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-s...@googlegroups.com.
To unsubscribe from this group, send email to prototype-scripta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
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:<table><thead><tr><th>Saved</th><th>Name</th><th>Rename</th><th>Delete</th><th>Switch Format</th><th>Browse</th></tr></thead><tbody><tr><td>11 Nov, 2009</td><td><a class="rsslink" href="savedsearches.php?cmd=rss&ssid=39" title="Access RSS Feed"> <img src="/images/icons/rss_16.png"> Sale less than x 250 thousand </a></td><td><a class="rename" href="user.php?cmd=savedSearchRenameForm&id=39">Rename</a></td><td><a class="delete" href="user.php?cmd=savedSearchDelete&id=39" title="Cannot undo."><img src="/images/icons/close_32.png" alt="delete"></a></td><td><a class="reformat" href="user.php?cmd=savedSearchSwitchFormat&id=39" title="Receive this by e-mail instead."><img src="/images/icons/rss_32.png"> <img src="/images/icons/arrow_right_16.png"> <img src="/images/icons/email_32.png"></a></td><td><a class="browse" href="search.php?cmd=search&formcat=residential&searchType=BUYSEARCH&searchOnPriceField=price&island=252&maxprice=250000"><img src="/images/icons/search_32.png" alt="view results"></a></td></tr><tr><td>25 Jun, 2012</td><td><a class="rsslink" href="savedsearches.php?cmd=rss&ssid=77" title="Access RSS Feed"> <img src="/images/icons/rss_16.png"> All the -plexes in NP </a></td><td><a class="rename" href="user.php?cmd=savedSearchRenameForm&id=77">Rename</a></td><td><a class="delete" href="user.php?cmd=savedSearchDelete&id=77" title="Cannot undo."><img src="/images/icons/close_32.png" alt="delete"></a></td><td><a class="reformat" href="user.php?cmd=savedSearchSwitchFormat&id=77" title="Receive this by e-mail instead."><img src="/images/icons/rss_32.png"> <img src="/images/icons/arrow_right_16.png"> <img src="/images/icons/email_32.png"></a></td><td><a class="browse" 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"><img src="/images/icons/search_32.png" alt="view results"></a></td></tr></tbody></table>
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+unsub...@googlegroups.com.
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-s...@googlegroups.com.
To unsubscribe from this group, send email to prototype-scripta...@googlegroups.com.
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.
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 '; }
}
At least by half ;-)
--
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/-/9U-Vxp9cZScJ.