0

I have created a popup using the lightweight jQuery plugin: bPopup.

I want the popup to appear on page load, and as such have the following code:

<script>
;(function($) {
  $(window).load(function(){ //see edit below
  $('#popup').bPopup({            
     opacity: 0.6,
     modalClose: true       
     });
    });
   })(jQuery);
</script> 

the customisation modalClose: true controls weather or not the popup is closed/dismissed on clicking on the popup, or surrounding overlay (see API)

However my popup successfully appears but does not dismiss, either when clicking on overlay OR when clicking on the element with the class that controls dismissal (by default, any element with class 'b-close' will also close the popup.

Any thoughts on where I am going wrong, or how I can find out what aspect is not working? Thanks

EDIT: As per a suggestion in comments I have altered $(window).load(function(){ to $(document).ready(function(){however my problem persists

Yotam Omer
  • 15,310
  • 11
  • 62
  • 65
Gideon
  • 1,878
  • 4
  • 40
  • 71
  • FYI, I think you should use $(document).ready() instead. This probably has no bearing on your question though. – Mike C. Mar 16 '13 at 14:31
  • ah ok - I'll change that and see: why is it that you think that? (I'm inexperienced, and wondering why the preference) – Gideon Mar 16 '13 at 14:32
  • 2
    have a look here http://stackoverflow.com/questions/3698200/window-onload-vs-document-ready as you'll see there, it shouldn't affect your problem, and what you have is not technically incorrect. – Mike C. Mar 16 '13 at 14:34
  • Mike, you grabbed the same exact question I did for ready vs load :) – David L Mar 16 '13 at 14:36
  • ok thanks, I'll take a look - as you guessed it has not fixed the problem, but I've edited my code to document ready now. Thanks – Gideon Mar 16 '13 at 14:36
  • All I can say about your current problem, is to debug the bpopup code and see where it is going wrong. How you do this depends on what dev tools you are using. – Mike C. Mar 16 '13 at 14:39
  • I looked at the developer's JSFiddle and it looks like modal: true is the default behavior. That said, without it or with it, it still works correctly. Only when I set it to false can I reproduce your problem. Why don't you make us a JSFiddle and we can take a look at it? – David L Mar 16 '13 at 14:40
  • @DavidL thanks for the suggestion - I crafted a jsfiddle, and couldn't replicate. Tried everything until I found out I was using a slightly out of date version of the plugin - using the latest one resolved the issue. Thanks for the indirect assist! – Gideon Mar 16 '13 at 17:42
  • @Gideon ah a bug in the version :). Those Plugins can get you. Glad you found a solution! – David L Mar 16 '13 at 18:31

1 Answers1

0

Discovered I was using 0.7.1 version of the popup, updated to 0.9.1 and that seems to have resolved the issue. Thanks to those who took a look.

Gideon
  • 1,878
  • 4
  • 40
  • 71