0

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>
Pranav C Balan
115k25 gold badges173 silver badges195 bronze badges
asked Jan 3, 2014 at 16:45
9
  • 1
    You're getting his error on which line ? Commented Jan 3, 2014 at 16:47
  • Does your Wordpress template include a reference to the jQuery library? Commented Jan 3, 2014 at 16:49
  • I don't see anything in your code that would throw that, unless you're doing window.jQuery = {} somewhere before this code. If you hadn't included jquery you would instead get undefined isn't a function. Commented Jan 3, 2014 at 16:50
  • Hi @enguerranws I got this exact error (anonymous function) ?eventid=9600&submit=Submit:226 x.event.dispatch jquery.js?ver=1.10.2:4 v.handle jquery.js?ver=1.10.2:4 Commented Jan 3, 2014 at 17:03
  • 1
    Look very closely at your fiddle and the code in your question. there's a very important difference. This spot in particular... ...Input").keyup(function () {... which is line 5 above. Commented Jan 3, 2014 at 17:10

1 Answer 1

2

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.

answered Jan 3, 2014 at 16:53
Sign up to request clarification or add additional context in comments.

1 Comment

Not my code, but here you have the original JSFIDDLE :) jsfiddle.net/ukW2C/3

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.