开发者

How can I open a Fancybox modal window with page content from a .js.erb file

开发者 https://www.devze.com 2023-04-03 06:22 出处:网络
I have a form that submits with Ajax. 开发者_开发技巧I want to respond by opening a Fancybox Modal window from within a js.erb file.

I have a form that submits with Ajax.

开发者_开发技巧I want to respond by opening a Fancybox Modal window from within a js.erb file.

How can I do this and have content loaded into the fancybox.

Thanks in advance.


<head>
    <script src="jquery-1.4.4.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.3.4.css" />

    <script type="text/javascript">
    $(function () {   //JQuery page onload

        divtoshow = '<div style="height: 250px; width: 400px;">'
            + '<h2>Modal Fancybox</h2>'
            + 'This is my message'
            + '<br /><br /><input type="button" value="Close" onclick="javascript:$.fancybox.close();" />'
            + '</div>';

        //Show fancybox
        $.fancybox(
            divtoshow,
            {
                'modal'     : true
                , 'height'  : 250
                , 'width'   : 400
            }
        );

    });   //JQuery page onload
    </script>
</head>
0

精彩评论

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