{"id":1695,"date":"2022-08-30T15:18:40","date_gmt":"2022-08-30T15:18:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/29\/fancybox-cant-open-partial-view-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:40","modified_gmt":"2022-08-30T15:18:40","slug":"fancybox-cant-open-partial-view-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/fancybox-cant-open-partial-view-collection-of-common-programming-errors\/","title":{"rendered":"Fancybox can&#39;t open partial view-Collection of common programming errors"},"content":{"rendered":"<p>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.<br \/>\nI don&#8217;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<\/p>\n<pre><code>@Html.ActionLink(\"Feedback\", \"New\", \"Feedback\", null, new { @class = \"lightbox\" })\n<\/code><\/pre>\n<p>JS<\/p>\n<pre><code>$(document).ready(function () {\n    $('.lightbox').fancybox();\n    \/\/ Another light box that works\n    $(\".fancybox-button\").fancybox({...\n<\/code><\/pre>\n<p>Action method<\/p>\n<pre><code>public ActionResult New()\n{\n   return PartialView();\n}\n<\/code><\/pre>\n<p>I also get this error in browser console:<\/p>\n<pre><code>Uncaught Error: Syntax error, unrecognized expression: \/Feedback\/New\nm.errorjquery-1.7.2.min.js:3\nm.filterjquery-1.7.2.min.js:3\nmjquery-1.7.2.min.js:3\nc.querySelectorAll.mjquery-1.7.2.min.js:3\nf.fn.extend.findjquery-1.7.2.min.js:3\ne.fn.e.initjquery-1.7.2.min.js:2\nejquery-1.7.2.min.js:2\ne.extend._startjquery.fancybox.pack.js:14\ne.extend.openjquery.fancybox.pack.js:6\ne.fn.fancybox.fjquery.fancybox.pack.js:33\nf.event.dispatchjquery-1.7.2.min.js:3\nf.event.add.h.handle.i\n<\/code><\/pre>\n<p>Code from separate demo project<\/p>\n<pre><code>\n\n\n\n\n\n    $(document).ready(function () {\n        $(\".fancybox\").fancybox();\n    });\n\n<\/code><\/pre>\n<ol>\n<li>\n<p>Make sure the DOM is ready when attaching the fancybox:<\/p>\n<pre><code>$(function() {\n    $('.lightbox').fancybox();\n});\n<\/code><\/pre>\n<p>Also make sure that the jQuery and fancybox scripts are properly referenced prior to the script in which you attempt to attach the fancybox.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-29 06:06:40. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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&#8217;t know if this is important but I have one more function that open images in fancybox (on the same page) and it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1695","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1695"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1695\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}