www.webdeveloper.com
Results 1 to 3 of 3

Thread: Form selector failing

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    233

    Form selector failing

    Hello all,

    I've just gone thru the process of re-factoring my plugin code only to find out, that a nasty error has been introduced somehow. Have tried to sort it out on my own for days now - am clueless.

    I've pin-pointed it down to the sub-statement that is not performing:

    It's about the following jQuery selector:

    Code:
    n = $("input[name][type=submit]", fm);
    Next, I test for n.length==0 which is firing but NOT desired.

    (fm contains a previously initialised jQuery form object, the length of which I've previously checked to be 1 (correct/expected) )

    I'd be extremely grateful if someone had an idea?

    Thanks in advance!

    Further background information:

    - You can see it failing on http://www.oeko-fakt.de/produkte/
    (press the button "Auswählen" and it will basically do nothing instead of correctly displaying a nice dataTables formatted form, which it had correctly done in previous versions so far)

    - The problem has arised or been introduced, since I've refactored the code, otherwise successfully. My first suspicion was maybe the odd local variable having too tight scope, but I do think it's the above expression failing...

    Any ideas?
    http://4nf.org/ - Ajaxify jQuery plugin

  2. #2
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    233
    Woke up this morning only to find out, that is was (briefly) working.
    Now it's back to faltering, without having changed anything in the code (!)

    So I'm wondering, whether it may be symptoms of too tight scoping of function variables after all, which could explain this rather random behaviour?

    If you "pass out" a variable from within inner function scope to it's client function, can that lead to random behaviour?

    (because I've observed that other areas of the plugin are now failing, too, without having changed the algorithm otherwise)

    Any hint would be greatly appreciated!
    http://4nf.org/ - Ajaxify jQuery plugin

  3. #3
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    233
    A while ago, I found an article on that it is NOT possible to pass variables, given rise to in inner functions to its client functions, and that it leads to unpredictable results.

    Here's something similar that points in the same direction:

    https://www.inkling.com/read/javascr...variable-scope

    So, to cut a long story short - is it possible to do something e.g. like this:

    function innerFn() { var o = new Object(...); ...; return o; } //this might lead to unpredictable results for the client??
    http://4nf.org/ - Ajaxify jQuery plugin

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles