这似乎是一个微不足道的问题,我可能会对语法感到困惑。
基本上,我希望FancyBox加载点击链接时的BB视图。
以前,它会加载BB路线,并重定向到具有所需视图和其他所有内容的页面:
$('.edit_list').show().attr('href', '#lists/' + list.id + '/edit')
我当前的观点
app.views.GlobalListEdit = Backbone.View.extend({
tagName: "div",
className: "global_list_edit list_view",
title: 'Edit - ',
template: _.template('<div class="error"></div>' +
'<label for="global_list_edit_name">Group Name</label>' +
... truncated ...
我当前的jquery
$('.edit_list')
.on('click', function(){
// $.fancybox({ href: '#' + '#lists/' + list.id + '/edit' });
// ^ bad idea #1 . This loads the whole other page sans the actual edit form..
// $.fancybox({ new app.views.GlobalListEdit({el: $('body')}).render() });
// ^ This psuedo code is more or less what I want. To load a new instant of the BB View.
return false;
});
所以我期待......
list.id
传递给该编辑调用。谢谢!
答案 0 :(得分:2)
你可以手持$.fancybox
一个jQuery对象,并且视图有$el
所以你可以这样做:
var v = new View({...});
$.fancybox(v.render().$el);
演示:http://jsfiddle.net/ambiguous/ncmd7/
或者你可以交出$.fancybox
DOM元素:
var v = new View({...});
$.fancybox(v.render().el);