I'm geting an Uncaught TypeError: Object is not a function
on WordPress when trying to filter a table using jQuery, my code is the following one. It works when it's not under WordPress so I guess I'm missing some kind of wrapping code on some function
Thanks to anyone who can save me in here!
Code:
<script type="text/javascript">
var link = true;
//<![CDATA[
jQuery(window).load(function($) {
jQuery("#searchInput").keyup(function($) {
//split the current value of searchInput
//create a jquery object of the rows
var jo = $("#fbody").find("tr");
if (this.value == "") {
jo.show();
return;
}
//hide all the rows
jo.hide();
//Recusively filter the jquery object to get results.
jo.filter(function(i, v) {
var $t = $(this);
for (var d = 0; d < data.length; ++d) {
if ($t.is(":contains('" + data[d] + "')")) {
return true;
}
}
return false;
})
//show the rows that match.
.show();
}).focus(function() {
this.value = "";
$(this).css({
"color": "black"
});
$(this).unbind('focus');
}).css({
"color": "#C0C0C0"
});
});//]]>
</script>
1 Answer 1
The first argument of .load() handler (and keyup) is an Event object, these methods don't work like .ready() method, the first argument of the .ready() handler refers to jQuery which is useful for avoiding conflicts with other libraries that use $. So you are (mis)using an Event object as jQuery.
window.jQuery = {}somewhere before this code. If you hadn't included jquery you would instead get undefined isn't a function....Input").keyup(function () {...which is line 5 above.