4

I am very noob to jquery and all about it. I am doing just one page ad hoc, so I got lost. I need to display iframe as and popup. How to do it?

I tried bpopup:

index.html is like:

<button id="my-button">POP IT UP</button>
<!-- Element to pop up -->
<div id="element_to_pop_up">
    <a class="b-close">x<a/>
    Content of popup
</div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/jquery.bpopup.min.js"></script>
<script src="js/jquery.easing.1.3.js"></script>
<script src="js/scripting.min.js"></script>

And according to homepage of bpopup i modified jquery.bpopup.min.js

// Semicolon (;) to ensure closing of earlier scripting
// Encapsulation
// $ is assigned to jQuery
;(function($) {

     // DOM Ready
    $(function() {

        // Binding a click event
        // From jQuery v.1.7.0 use .on() instead of .bind()
        $('#my-button').bind('click', function(e) {

            // Prevents the default action to be triggered. 
            e.preventDefault();

            // Triggering bPopup when click event is fired
            $('element_to_pop_up').bPopup({
        content:'iframe', //'ajax', 'iframe' or 'image'
        contentContainer:'.content',
        loadUrl:'http://dinbror.dk/search' //Uses jQuery.load()
    });


        });

    });

})(jQuery);

and I used default CSS setting like:

#element_to_pop_up { 
    background-color:#fff;
    border-radius:15px;
    color:#000;
    display:none; 
    padding:20px;
    min-width:400px;
    min-height: 180px;
}
.b-close{
    cursor:pointer;
    position:absolute;
    right:10px;
    top:5px;
}

Now the strange thing. There is an default js setting like $('#element_to_pop_up').bPopup(); that actually works, simple popup displays after clicking the button. But when I use Iframe setting (as above), nothing is happening. Nothing. Whyyyy? I am so confused with it.

Target is to display the popup when page loads. I have seen several hints, but none of them works. Which file to modify and how????

If you know how to help, please tell me. Just don't forget I am like a little child learning to walk. So don't skip any detail like "tie shoelaces". Thanks more than a lot.

Yotam Omer
  • 15,310
  • 11
  • 62
  • 65
Filip
  • 41
  • 1
  • 3

4 Answers4

5

Ok. I know the answer to this one. The problem is because you copied and pasted your code from their site and there is something wrong on it.

Look closely on the element identifier on this line:

$('element_to_pop_up').bPopup({.....

THEY DID NOT PUT THE # before the element_to_pop_up. Its supposed to be

$('#element_to_pop_up').bPopup({.....

after that your code should work

djot
  • 2,952
  • 4
  • 19
  • 28
user2828790
  • 51
  • 1
  • 2
0
<div id="element_to_pop_up">
<a class="b-close">x<a/>

<div class="content">
    Content of popup
</div>

</div>

just add an extra div with class "content". It should work.

0

Try adding "jquery-1.10.2.js" library to your page or latest version of it .

-1

There are a couple things to check. First, open the Chrome Dev Tools and watch the console. See if you are getting any errors when clicking on your button.

Second, check out the Network tab and make sure everything is loading correctly.

Can you post the code that actually works so we can see what is different?