Blog of Alexander Mamchenkov … mammoth cave …

Archive for May 21st, 2010

The GIMP

05.21.2010 · Posted in Personal

\"\"These  day I have a lot of talks about graphics/drawings/art around me. In most of the cases they also in clude talks about digital art. I am not a good painter or something, but being curious enough I went around my Fedora installation to check

what\’s there on this issue. Once again I tried to see what The GIMP can do and thus ended up drawing something. The idea is cool and since I used to draw some small sketches with pen while I was in school I decided that I will draw some stuff in The GIMP from time to time. Here is what I ended up with this time.

I have created a set on my Flickr page where I will be putting occasional drawings of mine :)

jQuery fancybox with ajax

05.21.2010 · Posted in Technology

I was fighting with bloody fancybox jQuery plugin the whole day yesterday. While it was working find on loading large image popups in normal scenarios, it was refusing to work when content was supplied through AJAX, meaning that DOM was altered after the fancybox was initialized.

Have tried several methods like using livequery plugin for jQuery, putting fancybox init in success callback of AJAX request and a lot of other things – non helped.

Finally, the solution was to put fancybox reinit in success callback of AJAX request, but not directly. Instead I had to use setTimeout method with delay of 600 to reinit fancybox as follows:

$.getJSON(ajax_url,function(HTML) {

    // populate my DOM with some HTML here

    // make fancybox reinit
    setTimeout(
        function() {
            $(\"a.some_fancy_box_element_class\").fancybox();
        },
        600
    );
});

This way it is working fine for me. Not sure why timeout is needed and what is the best delay time though. Can assume that DOM needs some time to insert all the elements and that by default fancybox was faster to check it than the actual update was finished.

Keep in mind that standard fancybox init should still remain in document ready event to adjust all elements on initial page load complete.