Problem Binding in IE

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem Binding in IE

Chris Pratt

I'm in the process of writing a jquery plugin that is similar to the
Humanized Transparent Message, but I'm running into a weird case where
jQuery.bind isn't working in IE.  The code is surprisingly short
(compared to some of the non jQuery versions I've written), but I'm
hoping someone can help me get around this sticky problem.

;(function($) {
  var alertDiv;

  $.alertboxDefaults = {
    confirm:     null,
    proceed:     "OK",
    cancel:      "Cancel",
    alertStyle:  "alertBox",
    buttonStyle: "button",
    topOffset:   100
  };

  $.alertBox = function (msg,args) {
    args = $.extend({},$.alertboxDefaults,args);
    alertDiv = $('#' + args.alertStyle);
    if(alertDiv.length == 0) {
      alertDiv = $("<div id=\"" + args.alertStyle + "\"><p>" + msg +
"</p></div>");
      alertDiv.appendTo("body");
    } else {
      alertDiv.empty().append("<p>" + msg + "</p>");
    }
    alertDiv.css("top",$(window).scrollTop() + args.topOffset);
    if(args.confirm != null) {
      var form = $("<form>");
      form.append("<input type=\"button\" class=\"" + args.buttonStyle
+ "\" value=\"" + args.proceed + "\"/>").click(function()
{ args.confirm(true); closeBox(); });
      form.append(" ");
      form.append("<input type=\"button\" class=\"" + args.buttonStyle
+ "\" value=\"" + args.cancel + "\"/>").click(function() { args.confirm
(false); closeBox(); });
      alertDiv.append(form);
    } else {
      $(window).bind('mousedown mousemove mousewheel keydown',
$.closeBox);
//      setTimeout("$(window).bind('mousedown mousemove mousewheel
keydown',$.closeBox);",Math.max(msg.split(/\s+/g).length * 175,1000));
    }
    alertDiv.fadeIn("fast");
    return this;
  }

  $.closeBox = function () {
    $.log("Closing Alert");
    $(window).unbind("mousedown mousemove mousewheel keydown",
$.closeBox);
    if(alertDiv.length > 0) {
      alertDiv.fadeOut("normal",function() {this.style.display =
"none";});
    }
  }

})(jQuery);

I've put breakpoints in $.closeBox and it's never getting called.  At
first I thought it was the setTimeout that was getting in the way, but
even with it commented out, the bind just isn't working in IE.  Any
ideas?
  (*Chris*)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Plugins" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/jquery-plugins?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Problem Binding in IE

boermans

On Dec 5, 6:01 pm, TheChrisPratt <[hidden email]> wrote:
> I'm in the process of writing a jquery plugin that is similar to the
> Humanized Transparent Message, but I'm running into a weird case where
> jQuery.bind isn't working in IE.  The code is surprisingly short
> (compared to some of the non jQuery versions I've written), but I'm
> hoping someone can help me get around this sticky problem.

Random suggestion - try binding to document instead of window.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Plugins" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/jquery-plugins?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Problem Binding in IE

Chris Pratt
Great random suggestion, that seems to have done the job.  Thanks.
  (*Chris*)

On Fri, Dec 5, 2008 at 8:05 PM, boermans <[hidden email]> wrote:

On Dec 5, 6:01 pm, TheChrisPratt <[hidden email]> wrote:
> I'm in the process of writing a jquery plugin that is similar to the
> Humanized Transparent Message, but I'm running into a weird case where
> jQuery.bind isn't working in IE.  The code is surprisingly short
> (compared to some of the non jQuery versions I've written), but I'm
> hoping someone can help me get around this sticky problem.

Random suggestion - try binding to document instead of window.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Plugins" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/jquery-plugins?hl=en
-~----------~----~----~----~------~----~------~--~---