It worked fine for me in Firefox. In order to make it work in IE

  self = this;
should be
  var self = this;

  Module = function() {
should be
  var Module = function() {

  $dialog = $("#my_dialog");
should be
  var $dialog = $("#my_dialog");

- Richard

On Tue, Dec 9, 2008 at 12:37 AM, Göran Törnquist <[EMAIL PROTECTED]> wrote:

>
> Hi, I'm in over my head with this one, and I can't seem to find the
> solution to make it work. I've taken some time to break out the code for the
> problem, and below is the code that manifests my dilemma.
>
> This code presents a simple table with rows that are tagged with row id's.
> When the user clicks on a link inside a row I present a confirmation dialog
> and then if the user clicks "Yes", then I'll execute the provided callback.
>
> What is going wrong is that the last alert (from the callback) only works
> correctly once - namely the first time. Whatever value the alert presents
> the first time, is also what will be presented the following times until
> reload of script.
>
> I would be most grateful for some help.
>
> /Göran
>
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="sv" lang="sv">
> <head>
>   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
>   <link rel="Stylesheet" href="jquery/themes/default/ui.all.css"
> type="text/css"  media="all" hreflang="css/all" charset="utf-8" />
>   <script src="jquery/jquery-1.2.6.js" language="Javascript"
> charset="utf-8"></script>
>   <script src="jquery/ui/jquery.ui.all.js" language="Javascript"
> charset="utf-8"></script>
> </head>
> <body>
> <table class="sometable">
>   <tr id="rec_1"><td><a href="#">First record</a></td></tr>
>   <tr id="rec_2"><td><a href="#">Second record</a></td></tr>
>   <tr id="rec_3"><td><a href="#">Third record</a></td></tr>
>   <tr id="rec_4"><td><a href="#">Fourth record</a></td></tr>
>   <tr id="rec_5"><td><a href="#">Fifth record</a></td></tr>
>   <tr id="rec_6"><td><a href="#">Sixth record</a></td></tr>
>   <tr id="rec_7"><td><a href="#">Seventh record</a></td></tr>
> </table>
> <script type="text/javascript">
>   Module = function() {
>       self = this;
>             return {
>           //Present a dialog with "Yes" and "No" buttons. Execute provided
> callback for respective button.
>           confirm: function(msg, yesCB, noCB, options) {
>               $dialog = $("#my_dialog");
>                             if($dialog.length == 0) {
>                   $("body").append('<div id="my_dialog"><p></p></div>');
>                   $dialog = $("#my_dialog");
>   }
>                                 var buttons = {};
>               buttons["Yes"] = function(){
>                   $dialog.dialog("close");
>                   if($.isFunction(yesCB))
>                       yesCB();
>               };
>               buttons["No"] = function(){
>                   $dialog.dialog("close");
>                   if($.isFunction(noCB))
>                       noCB();
>               };
>               var myOptions = {
>                   buttons: buttons,
>                   modal: true,
>                   overlay: {
>                       opacity: 0.7,
>                       "background-color": "#000"
>                   }
>               };
>               $.extend(myOptions, options);
>                             $dialog.find("p").html(msg);
>               $dialog.dialog(myOptions).dialog("open");
>           }
>       }
>   }();
>       $(function() {
>       $(".sometable a").click(function() {
>           var $parentTR = $(this).parents('tr').eq(0);
> //select the first occurrence of a <tr> that is a parent of this
>           var id = $parentTR.attr('id').replace(/rec_(.*)/i,"$1");
>  //grab the integer part of the id
>           alert("Click: " + $parentTR.attr("id"));
>           Module.confirm(id,        //call the piggybacked script
>               function() {
>                   alert("You said yes to record " + id);        // <=====
> HERE is the problem
>               }
>           );         })
>   });
>  </script>
> </body>
> </html>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>

Reply via email to