Search code examples
javascriptjquerytumblr

after clicking {Permalink}, call function


I need to bind a function to initialize a js plugin after {Permalink} is clicked so Tumblr IPA "redirects" the browser to a new page, with the post details.

How can I do so? There's not so much documentation on how {Permalink} really works, whether it's ajax or whether it has some callback function (which I would appreciate).

Of course this would try to initialize before the "new" page is loaded. I think it's ajax though.

        $("#{Permalink}").click(function() {
               $('.jqzoom').jqzoom({
                    zoomType: 'standard',
                    lens:true,
                    preloadImages: false,
                    alwaysOn:false
                });
        });

Solution

  • {Permalink} renders a string that is the URL to the post: http://sample.tumblr.com/post/123

    For reference, Tumblr theme operators don't have anything to do with javascript. They render mainly strings.

    You need to bind the actual element that is clicked:

    HTML

    <a href="{Permalink}" class="permalink">...</a>
    

    jQuery

    $(".permalink").click(function() {
        ...
    });
    

    Reference: http://www.tumblr.com/docs/en/custom_themes#posts