Buyin Brian
Buyin Brian

Reputation: 2991

PrettyPhoto/jQuery load from click

I'm a bit new to jQuery and I'm trying to do something that I would think is straightforward, but I cannot seem to crack it.

I want to create a function that loads different videos when you click on a button. All of the samples for PrettyPhoto that I have seen are using tags in the html, not JS click.

To summarize my code, I have something along the lines of:

$("#button1").click(function() {
  openMovie("myMovie.mp4");
}); 


function openMovie(url) {
  //open up the movie at the url passed into the function as a lightbox with PrettyPhoto    
}

I would think this would be simple, but I can't seem to find any info on how to do it. The documentation is all inline html

I was able to find some code online for images that I altered, but it throws an error:

$("a[rel^='prettyPhoto']").prettyPhoto();
$.prettyPhoto.open(['assets/myMovie.mp4'],['Test']);

**

Image cannot be loaded. Make sure the path is correct and image exist.

**

Any help would be greatly appreciated.

Upvotes: 1

Views: 1957

Answers (1)

Buyin Brian
Buyin Brian

Reputation: 2991

I was able to get this working by changing the code:

$("a[rel^='prettyPhoto']").prettyPhoto();

to

$("a[rel^='prettyPhoto[movies]']").prettyPhoto();

Upvotes: 1

Related Questions