Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug on winEvents for binding the event 'beforeunload' #7

Open
ghost opened this issue Aug 26, 2013 · 1 comment
Open

Bug on winEvents for binding the event 'beforeunload' #7

ghost opened this issue Aug 26, 2013 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 26, 2013

When I use winEvents on a brite view,
When I bind the event beforeunload thanks the 'winEvents' of briteView, nothing appened.
With the same function binding directly, with 'on', it's work.

Below, an example of code :

beforeUnloadFn = function(e){
        var confirmationMessage = "\o/";
        (e || window.event).returnValue = confirmationMessage;     //Gecko + IE
        return confirmationMessage; 
      }
      brite.registerView('Test', {
        create: function(){
          return '<div style="background-color:red;height:50px;width:50px;"></div>'
        },
        winEvents: {
          //  No effect
          'beforeunload': beforeUnloadFn
        }
      });
      $(document).ready(function(){
        brite.display('Test', 'body');
        //  work
        //$(window).on("beforeunload", beforeUnloadFn);
      });
@ghost
Copy link
Author

ghost commented Nov 14, 2013

I get the last brite-snapshot version. And I reproduce the bug on firefox and chrome.
I was not clear on my example.
When I bind the event beforeunload with on of jQuery, it's work :

beforeUnloadFn = function(e){
  var confirmationMessage = "\o/";
  (e || window.event).returnValue = confirmationMessage;     //Gecko + IE
  return confirmationMessage; 
}
$(document).ready(function(){
  $(window).on("beforeunload", beforeUnloadFn);
}

Here the fiddle : http://jsfiddle.net/KGFke/ . If you click on run, you will see a popup.
And when I use the brite event it doesn't work :

beforeUnloadFn = function(e){
  var confirmationMessage = "\o/";
  (e || window.event).returnValue = confirmationMessage;     //Gecko + IE
  return confirmationMessage; 
}
brite.registerView('Test', {
  create: function(){
    return '<div style="background-color:red;height:50px;width:50px;"></div>'
  },
  winEvents: {
    //  No effect
    beforeunload': beforeUnloadFn
  }
});
$(document).ready(function(){
  brite.display('Test', 'body');
}

Here the fiddle : http://jsfiddle.net/MHf2j/ . If you click on run, no popup appears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants