Pregunta

I recently came across Harvey.js and am very happy with it. Now, i'm trying to integrate it with Modernizr.load (Yepnope), with little success.

You can get an idea of what I'm trying to do with this code snippet:

Modernizr.load({
    test: Harvey,
    nope: '<?php bloginfo('stylesheet_directory'); ?>/js/harvey.js',
    complete: function(){
        Harvey.attach('screen and (max-width: 960px)', {
            on: function(){ $('ul#menu-primary').each(menuReplace) },
            off: function(){ $('#navigation nav').empty().append(menu) }
        });
        if( !smallV ){
            $('.responsivize').each(function(){
                var me = $(this),
                data = me.data();
                data.src = data.fullsrc;
                delete data.fullsrc;
                $('<img />', data).insertBefore(me)
                me.remove()
            });
         }
     }
});

When I give it a go, the browser throws a "function not defined error" and the page dies.

Any idea how to make the YepNope test whether a function is available?

EDIT: The reason why I'm testing for the function, is because I have two similar code blocks further in the code that use Harvey. I figured it was an easy way to double check that the script was properly loaded.

Thanks all.

¿Fue útil?

Solución

Seems like this works, if anyone was wondering.

!typeof(Harvey)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top