Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ-For-Javascript Nested Arrays
    primarykey
    data
    text
    <p>The <a href="http://linqjs.codeplex.com/" rel="nofollow">Linq-For-Javascript</a> library contains functions that convert between "<code>jQuery objects</code>" and "<code>Enumerable objects</code>": toEnumerable() and TojQuery(). Consider the difference between these two lines:</p> <pre><code>$('tr'); // returns array of tr $('tr').toEnumerable().TojQuery(); // returns array of tr[1] </code></pre> <p>Converting from jQuery to Enumerable and back to jQuery does not give you what you started with. The end result is an array of arrays of elements, with each sub-array having a length of 1. I do need to make use of Enumerable, so this is just a convenient example of my problem.</p> <p>This means that to get the id of an element, you'd need to do the following:</p> <pre><code>$('tr')[0].id; // returns "myID" $('tr').toEnumerable().TojQuery()[0][0].id; // returns "myID" </code></pre> <p>I'm surprised of this, because even though I've allegedly gone back <code>TojQuery()</code>, the object returned by <code>TojQuery()</code> does not work with typical jQuery calls:</p> <pre><code>$('tr').find('td').length; // returns 170 (in my case) $('tr').toEnumerable().TojQuery().find('td').length; // returns 0 (BAD) </code></pre> <p>I would like it if both lines returned 170, but apparently Linq-For-Javascript doesn't work that way.</p> <p>So, my <strong>questions</strong>:</p> <ol> <li>Why is this?</li> <li>Am I doing it wrong?</li> <li>If not, any good workarounds? (convert <code>array of 1-element arrays</code> to <code>array of elements</code>?)</li> </ol> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload