开发者

Jquery, Modal,Lightbox Popup - open automatically with Java Call

I've searched and searched and tried and tried but I can't find an answer to my question - any help greatly appreciated.

I trying to get a Jquery modal popup of any description (I really don't mind which one I use) to launch automatically when called from Java.

I can get the popups to work, get them to work on pageload but I need it to be able to launch from a bit of Java script.

I'll explain...currently I have a from that uses some Java to check any entry as it typed against a database. If the entry is not present, a second form opens on a new page to enable the individual to make an entry.

This all works perfectly the only thing I'd like to change is to have the second form open in a nice popup such as fancybox/colorbox/lytebox etc.

Currently I have this bit of Java

function findValue(li) {
if( li == null ) return window.location = "http://www.gotosecondform.com"

All a want to do is be able to call a nice popup iframe rather than go to the web address.

Could anybody help and explain the best way to do this? -开发者_如何学运维 I suspect it's quite simple but I just can't find anything on the net that isn't based on page load and clickable links.

I'm not fussed in regard to which Lightbox spin off I use.

Thanks in advance and all example greatly appreciated.

Chris


I assume by Java you mean Javascript. Java and Javascript is not related. As to your question, is this what you are looking for? I've used jquery UI

http://jqueryui.com/demos/dialog/

First, initialize the modal, but don't open it

$( ".selector" ).dialog({ autoOpen: false }); //add any other options you want

To open it in your method

function findValue(li) {
    //if( li == null ) return window.location = "http://www.gotosecondform.com"
    $( ".selector" ).dialog("open")
}

That's it!

EDIT - Made it work with an iframe

Well, you could wrap it in an iframe and put it in there if you want.

Your HTML

<div class='selector'>
   <iframe src='' id='iframe'></iframe>
</div>

Your new JS

function findValue(li) {
    if( li == null ) {
       $('#iframe').attr('src, 'http://www.gotosecondform.com');
       $( ".selector" ).dialog("open") 
    }

}

There you go, iframe in a JQUI dialog. Of course, you'll need to style it appropriately. But this should give you the base

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜