문제

Is there a Javascript component that allows me to simply pass it a string made up of arbitrary HTML (any HTML I wish to use) and will show that HTML in a lightbox?

I've been scouring the internet, searching for examples, but it seems like there simply isn't any component capable of doing this.

Even LightWindow, which claims to be all-purpose, still requires me to attach it to an tag with the href set to an element ID.

This isn't what I want. I want to be able to call a function and pass in the HTML myself.

(Another issue with LightWindow is that it requires scriptaculous as a dependency. The project already uses jQuery, and I'd rather not include two frameworks at once.)

Any ideas?

도움이 되었습니까?

해결책

colorbox is great. It relies on JQuery.

To use it with an html string, you would call it like this:

$.colorbox({html:'<p>Hello</p>'});

다른 팁

You can use jqModal or jQuery UI dialog.

SLaks is correct. You should definitly use JQuery UI dialog. Here is an example of using the JQuery dialog as a modal, very similar to using lightbox.

$("#dialog-message").dialog({modal: true});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top