簡體   English   中英

在Colorbox中單擊按鈕后,如何呈現表單?

[英]How can I render a form after a button is clicked in Colorbox?

我正在嘗試在Colorbox中實現一個按鈕,該按鈕將更新模態並渲染表單。

Pinterest的添加功能就是一個例子。 “主頁>添加圖釘>圖釘URL”

我嘗試復制Colorbox的內聯HTML示例。

<script type="text/javascript">
$(document).ready(function () { 
    $(".inline").colorbox({inline:true, width:"50%"});

    $('a[rel="colorbox"]').live("click", function() {

    $.colorbox({
        open: true,
        href: this.href
    });

    return false;
    });
});
</script>

        <div style='display:none'>
            <div id='inline_content' style='padding:10px; background:#fff;'>
            <p><strong>Add a Promotion</strong></p>
            <p><a id="click" href="#" style='padding:5px; background:#ccc;'>Click me, it will be preserved!</a></p>
            <p><strong>If you try to open a new ColorBox while it is already open, it will update itself with the new content.</strong></p>
            <p>Updating Content Example:<br />
            <a class="ajax" href="**shared/promotion_form**" rel="colorbox">Add a Promotion</a></p>
            </div>
        </div>

問題在於表單是_promotion_form.html.erb,因此我無法鏈接到它。

嘗試將選擇器上移,然后更新到jQuery 1.7.1,也許是這樣的:

$('body').on("click", "a[rel="colorbox"]", function() {

因此,通過這種方式,您可以在主體中監視具有選擇器“ a [rel ='colorbox']”的任何元素。

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM