I'm building a plugin to WordPress and so far so good with the PHP library. But I am having some issues with the JavaScript API.
I'm trying to use it with jQuery, and I think the WordPress version of jQuery is messing with the $f
shortcut. Why wouldn't this work?
var vimeoPlayer = {
init: function() {
var vimeoPlayers = document.querySelectorAll('iframe'),
player;
jQuery('iframe.vimeo-player').each(function(index, iframe){
player = vimeoPlayers[index];
$f(player).vimeoPlayer.addEvent('ready', vimeoPlayer.ready);
});
},
addEvent: function(element, eventName, callback) {
if (element.addEventListener) {
element.addEventListener(eventName, callback, false);
}
else {
element.attachEvent(eventName, callback, false);
}
},
ready: function(player_id) {
alert(player_id);
}
}
jQuery(document).ready(function($){
vimeoPlayer.init.call();
});
You can see it in action at temp.woodshop.tv/?work/?dickies-campaign/?
.
I get this error:
TypeError: Result of expression '$f(player).vimeoPlayer' [undefined] is not an object.