Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » can't make jquery pop up work

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2561 Views
  • theoldlr
    Avatar
    Community Member
    103 Posts

    can't make jquery pop up work Link to this post

    Hello,

    I have a VideoHolder page type with a bunch of links to flash videos. I want each link to a video to open in a popup window. I am trying to use the jquery found here. I can't make this code work... I either get errors in the jQuery or the page just opens normally. I have added the proper class to the a tag for the link, and have included the javascript in the VideoHolder page type.

    I think what is not connecting for me is how to include the script given in demo1 code example along with the entire file properly in SS. Any guidance much appreciated!

  • carlos
    Avatar
    Community Member
    41 Posts

    Re: can't make jquery pop up work Link to this post

    Hi theoldlr,

    you can add a js file like this (in VideoHolder controller)

    public function init(){
    parent::init();
    Requirements::javascript('path/to/jquery.popupWindow.js');
    }

    hope it helps.
    cheers
    Carlos

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: can't make jquery pop up work Link to this post

    Carlos,

    I have included the code to require the javascript file in the videoholder as you described. However, if you look at the example1 demo code:

    <p><a href="http://www.yahoo.com" title="yahoo.com" class="example1demo">open popup</a></p>
    <script type="text/javascript">
    $('.example1demo').popupWindow({
    height:500,
    width:800,
    top:50,
    left:50
    });
    </script>

    Can i include the short jQuery statement that tells the script which class is supposed to popup into the jquery.popupWindow.js ? This is what I am not sure how to do.

    Thanks

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: can't make jquery pop up work Link to this post

    I got it to work... just needed to add this to the beginning of the .js file:

    jQuery(document).ready(function(){
    jQuery('.videoLink').popupWindow();
    });

    So much easier than I thought.

    2561 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.