For the last few hours I've tried getting YepNope and some Modernizr tests working, but without any luck.
Modernizr is loaded in the head, jQuery, plugins.js
and script.js
at the bottom of the page (in that order). Nothing fancy, but handy because every resource called in scripts.js
is already available when executed. All scripts are loaded correctly, the test is the only scripting going on.
I want to test if need to load a polyfill for form validation, so this is the test: Modernizr.formvalidationapi
. Of course I made sure that Modernizr.addTest
and the forms-validation
non-core detect is included in my build, together with HTML5 input types & attributes and Modernizr.load
, which is basically yepnope.js
So in my script.js
, there is the following:
yepnope({
test : Modernizr.formvalidationapi,
yep : alert("yep"),
nope : alert("nope")
});
I added the alerts just to debug of course.
I tested this in Safari 6.0.2 and Firefox 18.0.2, both times it alerts "yep", followed by "nope", so I assume there is an error somewhere.
I also tried to wrap the code in a document ready wrapper, which changed nothing.
As jQuery runs in no conflict mode inside Wordpress I believe ("$" can't be used, instead "jQuery" has to be used), I included this to remap the dollar sign to jQuery:
(function($){})(window.jQuery);
It also did nothing.
At the moment I believe it has something to do with Wordpress' own wp_register_script
and wp_enqueue_script
, but I am not sure as I think it is possible to use Modernizr tests in a Wordpress site.
Where am I going wrong?
P.S.: I am aware that there is also http://wordpress.stackexchange.com, but I posted my question here because I believe the problem lies inside my script and not Wordpress. If you wish, I can post the question there of course.
Ok I was just being stupid non-stop. Instead of Modernizr.formvalidationapi
I have to test Modernizr.formvalidation
to get everything working. What a waste of time that was, ha.