Javascript 在Colorbox中单击按钮后,如何呈现窗体?

Javascript 在Colorbox中单击按钮后,如何呈现窗体?,javascript,jquery,render,colorbox,Javascript,Jquery,Render,Colorbox,我正在尝试在颜色框中实现一个按钮,它将更新模式并呈现表单 Pinterest的添加功能就是一个例子 我尝试过复制Colorbox的内联HTML示例 <script type="text/javascript"> $(document).ready(function () { $(".inline").colorbox({inline:true, width:"50%"}); $('a[rel="colorbox"]').live("click", function

我正在尝试在颜色框中实现一个按钮,它将更新模式并呈现表单

Pinterest的添加功能就是一个例子

我尝试过复制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>

$(文档).ready(函数(){
$(“.inline”).colorbox({inline:true,宽度:“50%”);
$('a[rel=“colorbox”]”)。live(“单击”,函数(){
$彩色盒({
开放:是的,
href:this.href
});
返回false;
});
});
添加促销活动

如果您试图在新的颜色框已打开时打开它,它将用新内容更新自身。

更新内容示例:


问题是表单是_promotion_form.html.erb,因此我无法链接到它

尝试将选择器向上移动一个级别,并更新到jQuery 1.7.1 也许是这样的:

$('body')。在(“单击”,“a[rel=“colorbox”]”上,function(){

因此,通过这种方式,您可以查看具有选择器“a[rel='colorbox']”的任何元素的主体


希望这有帮助。

选择器现在可以工作。我遇到的问题是,我不知道如何呈现促销表单,而不是通过href链接。哦……只需使用html属性而不是href属性,值将是字符串或jQuery对象。