0

I have written code to hide row for some criteria. It is working for some time, now it is not working found that jQuery.fn.jQuery.init[1] is returning jQuery.fn.jQuery.init[1] for the method .closest('tr'). Can some one suggest it why this issue is causing?

function applyfilter(ele) {
    $.ajax({
        cache: false,
        async: true,
        type: "POST",
        dataType: "json",
        url: "WebForm4.aspx/Calc",
        data: "",
        contentType: "application/json; charset=utf-8",
        success: function (response) {
            if (response.d > range) {
                var row = $(ele).closest('tr');
                var tr = $(row)[0];
                $(row).remove();
                return true;
            }
        },
    });
}
Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
  • 1
    Many jQuery methods return a jQuery object, which in the browser might be logged as `jQuery.fn.jQuery.init` (because that's the function with which the objects was constructed). So does `.closest`. If you have a particular problem with your code, you should post it. – Felix Kling Dec 09 '13 at 01:27
  • There is no such thing as `jQuery.fn.jQuery.init[1]`. What do you mean, the `jQuery.fn.init` constructor? – Bergi Dec 09 '13 at 01:29
  • @Bergi: Chrome shows the number of elements inside an array-like object in brackets after the constructor name. I assume that's what the OP is referring to. – Felix Kling Dec 09 '13 at 01:30
  • @Felix: Yeah, probably, though I would expect a space before the `[1]` and do still think there's one `.jQuery` too much – Bergi Dec 09 '13 at 01:36
  • function applyfilter(ele) { $.ajax({ cache: false, async: true, type: "POST", dataType: "json", url: "WebForm4.aspx/Calc", data: "", contentType: "application/json; charset=utf-8", success: function (response) { if (response.d > range) { var row = $(ele).closest('tr'); var tr = $(row)[0]; $(row).remove(); return true; } }, }); } – Kota Pavan Kumar Dec 09 '13 at 01:37
  • @Bergi: When I do `console.dir($())` on SO, I get, `e.fn.e.init[0]`, so the double jQuery must be correct. – Felix Kling Dec 09 '13 at 01:38
  • @user1003086: Please [edit] your question and provide further explanation of your problem. Code in comments is not readable. – Felix Kling Dec 09 '13 at 01:39
  • If you could indent your code and [format it properly](http://stackoverflow.com/editing-help#code), then we would be able to actually read it. Btw, you still haven't explained the problem. That `.closet('tr')` shows `jQuery.fn.jQuery.init[1]` in the console is the **normal behavior**. If that's all your question is about then you don't actually have a problem. – Felix Kling Dec 09 '13 at 01:40
  • @FelixKling, I am calling webmethod in my apply filter , based on the result I am hiding the row – Kota Pavan Kumar Dec 09 '13 at 01:42
  • OK, but what is the **problem**? (I edited the question so that the code is readable, please do it yourself next time). – Felix Kling Dec 09 '13 at 01:43
  • Thanks for correcting it ... Unable to hide the row due to return of jQuery.fn.jQuery.init[1] object... – Kota Pavan Kumar Dec 09 '13 at 01:48
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/42763/discussion-between-user1003086-and-felix-kling) – Kota Pavan Kumar Dec 09 '13 at 01:49
  • 1
    @Felix: Ah, I now found [this interesting question](http://stackoverflow.com/q/19758295/1048572). Probably happens when Chrome is trying to make an identifier for an unnamed function. – Bergi Dec 09 '13 at 01:50
  • @user1003086: No, the fact that it returns a "jQuery.fn.jQuery.init[1] object" is not the problem. That's **normal**. The problem must be somewhere else, but without more information there is little we can do. – Felix Kling Dec 09 '13 at 01:56
  • @FelixKling, I am trying to find the issue, will you suggest me how to hide or remove the tr in case of jQuery.fn.jQuery.init[1] – Kota Pavan Kumar Dec 09 '13 at 02:03
  • Since I don't know anything else about the context, I cannot help you. I can only recommend to [learn how to **debug** JavaScript](http://www.creativebloq.com/javascript/javascript-debugging-beginners-3122820), so that you can help yourself. – Felix Kling Dec 09 '13 at 02:11
  • Don't you want `$(tr).remove()` not `$(row).remove()`? – jasonscript Dec 09 '13 at 02:18

0 Answers0