Fancybox can't open partial view-Collection of common programming errors
I want to open partial view in fancybox like a modal view but when I click on the link it opens whole new page but it should open that in fancybox.
I don’t know if this is important but I have one more function that open images in fancybox (on the same page) and it works. Class names are different
@Html.ActionLink("Feedback", "New", "Feedback", null, new { @class = "lightbox" })
JS
$(document).ready(function () {
$('.lightbox').fancybox();
// Another light box that works
$(".fancybox-button").fancybox({...
Action method
public ActionResult New()
{
return PartialView();
}
I also get this error in browser console:
Uncaught Error: Syntax error, unrecognized expression: /Feedback/New
m.errorjquery-1.7.2.min.js:3
m.filterjquery-1.7.2.min.js:3
mjquery-1.7.2.min.js:3
c.querySelectorAll.mjquery-1.7.2.min.js:3
f.fn.extend.findjquery-1.7.2.min.js:3
e.fn.e.initjquery-1.7.2.min.js:2
ejquery-1.7.2.min.js:2
e.extend._startjquery.fancybox.pack.js:14
e.extend.openjquery.fancybox.pack.js:6
e.fn.fancybox.fjquery.fancybox.pack.js:33
f.event.dispatchjquery-1.7.2.min.js:3
f.event.add.h.handle.i
Code from separate demo project
$(document).ready(function () {
$(".fancybox").fancybox();
});
-
Make sure the DOM is ready when attaching the fancybox:
$(function() { $('.lightbox').fancybox(); });
Also make sure that the jQuery and fancybox scripts are properly referenced prior to the script in which you attempt to attach the fancybox.
Originally posted 2013-11-29 06:06:40.