[英]Popup Fancybox 2 window with ajax loaded content
After doing some research on the small documentation provided on the official fancybox 2 site and all posts here in stackoverflow I am unable to get this fancybox 2 working. 在对fancybox 2官方站点上提供的小型文档以及stackoverflow中此处的所有帖子进行了一些研究之后,我无法使fancybox 2正常工作。
I have a jquery autocomplete component that the user uses to search for some entity. 我有一个jquery自动完成组件,用户可用来搜索某些实体。 After the user finds the right entity and selects it, I want to popup a fancybox showing the possible actions to perform over this entity (edit, assign to, delete, blah blah blah). 用户找到正确的实体并将其选中后,我想弹出一个花式框,显示对该实体执行的可能操作(编辑,分配,删除,等等)。
I will pass the id of the selected entity to the fancybox on the GET parameter of the url I want to load via ajax. 我将所选实体的ID传递给我想通过Ajax加载的URL的GET参数上的fancybox。
The thing is that the options i want to show will be dynamically shown because they depend on the selected entity and on the user permissions. 事实是,我要显示的选项将动态显示,因为它们取决于所选实体和用户权限。
Everythings is working perfectly but I am unable to get the fancybox popup with the url loaded. 一切正常,但我无法加载URL的fancybox弹出窗口。
This is the sample JS code for the fancybox I am trying to show: 这是我尝试显示的fancybox的示例JS代码:
$('#inputsearchbox').autocomplete({
source: function(request, response) {
var results = $.ui.autocomplete.filter(json_list, request.term);
response(results);
},
close: function(event, ui){
},
select: function(event, ui) {
event.preventDefault();
console.log(ui.item);
$.fancybox({
type: 'ajax',
href : '/some-script.php',
scrolling : 'no',
transitionIn : 'fade',
transitionOut : 'fade'
});
},
focus: function(event, ui) {
event.preventDefault();
},
delay: 700,
minLength: 2
});
Any help will be appreciated. 任何帮助将不胜感激。
Found it! 找到了!
I was missing the call to the function .open. 我错过了对函数.open的调用。
I just replaced $.fancybox for $.fancybox.open and it worked like a charm. 我只是将$ .fancybox替换为$ .fancybox.open,它像一种魅力一样工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.