javascript - Fancybox 1.2.5 callbackOnShow - I have some syntax errors -


i trying run function when box loads, v1.2.5 seems should callbackonshow attribute. here code, have syntax error noob, having trouble figuring out.

$("a#inline").fancybox({             'hideoncontentclick': false,             'autodimensions': false,             'framewidth': 932,             'frameheight': 496,             'padding': '0',             'overlayopacity': '0.7',             'callbackonshow': $(function () { $('#palette').on('mouseover', 'a', function (event) {     $('#palettecolorname').text("color: " + event.target.title); }); $('#palette').on('mouseleave', 'a', function () {     $('#palettecolorname').text("color: "); }); }); 

possible alternatives welcome to. here fiddle version of trying functioning inside fancybox.

js fiddle

a few things there. shouldn't enclose options in quotes.

$("a#inline").fancybox({    hideoncontentclick: false,    autodimensions: false    //etc... }); 

next, you're not specifying callback functions quite right. writing function this: callback: $(function() { ... }); function executed. don't want that... want function run on event. should this:

$('a#inline').fancybox({     callbackonshow: function() {         $('#palette').on('mouseover', 'a', function(event) {             //...         });     } }); 

i'm not sure if it's way in text editor you're using, or formatting got messed when pasted code here, while not strictly necessary, it's very idea use proper indenting. makes lot easier spot syntax errors.

finally, should consider installing firebug firefox, if don't have already. out figuring out have syntax error.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -