Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

can't make jquery pop up work


Reply


4 Posts   2623 Views

Avatar
theoldlr

Community Member, 103 Posts

19 March 2010 at 7:16am

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 [url=http://swip.codylindley.com/popupWindowDemo.html]here[/url]. 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!

Avatar
carlos

Community Member, 41 Posts

19 March 2010 at 3:12pm

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

Avatar
theoldlr

Community Member, 103 Posts

20 March 2010 at 4:49am

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

Avatar
theoldlr

Community Member, 103 Posts

20 March 2010 at 9:17am

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.