I'm trying to stop a fancybox dialog with html buttons in content without using help or tpl. But without success
HTML
& lt; Div id = "open" & gt; Open & lt; / Div & gt; & Lt; Div id = "modal" & gt; & Lt; / Div & gt; My code
$ ('# open') ('Click', function () {var btn = '
How can you do that? Thanks
I will make some changes to your code.
-
Since you are calling
modalthis waymodal ("html content here" + btn );... You must pass function such as parameter
var modal<... -
Even if you are filling
#modalcontainers such as$ ('# Modal') HTML (MSG).... you need to tell the fancybox to target the container as fancy box content by adding the
hrefAPI option :href: "#modal"btw
beforeLoadinstead ofbeforeShowinstead of the callback Use content to be filled with.html ()methodLoad first: function () {$ ('# modal'). Html (msg); } -
Your
BTNobject to the$. The target is not missing on the fancybox.close ()method inclick:var btn = '& lt; Br> & Lt; A href = "javascript: jquery.fancybox close ();" & gt; Closed & lt; / A & gt; '; Then your last code should look like this:var modal = function (msg) {$ .fancybox ({MinHeight: 100, // autoScale: true, // v2.x for autoSize Not valid choice: true, // autoHeight: true, // is not required because autoSize is true / autoWidth: true, fitToView: true, // CloseBtn: false, // is not required because the model is true Model: True, Href: "#modal", Load first: function () {$ ('# modal') .HTML (msg);}}); } JQuery (document) .ready (function ($) {$ ('# Open'). ('Click', function () {var btn = & lt; br & gt; & lt; a href = "javascript : JQuery.fancybox .close (); "& gt; Turn off & lt; / a & gt; '; Model (" html content here "+ BTN);});}); //
Comments
Post a Comment