-
Feb 20th, 2021, 04:47 PM
#1
[jQuery] .each() on a regular array
jQuery is so powerful when you work the DOM - the methods available do so much, once you get fully versed in them.
The .each() method is meant to work an array of "wrapped-elements" - DOM elements specifically.
But it can be used for a neat loop on any array.
In the image below we have an array of objects: layout(46) and I want to iterate along those objects and build a "printable" multi-line string.
$(...) calls the jQuery library, for those not used to seeing syntax like that. The "$" sign introduces the library call.
Here is the code. Looks a lot like LINQ in .net. I'll post a screen shot of the "popup errorMessage" in the next post.
Code:
var strLayout = "";
.
.
.
$(g_objGrid[intGO].awcoptions.reportinfo.layout).each(function () {
strLayout += (strLayout.length != 0 ? "<br />" : "") + $.toJSON(this);;
});
errorMessage("Report Layout", strLayout);
Last edited by dday9; Feb 22nd, 2021 at 11:06 AM.
-
Feb 20th, 2021, 04:47 PM
#2
Re: jQuery .each() on a regular array
Here is the result string in that errorMessage() popup function.
-
Feb 20th, 2021, 04:55 PM
#3
Re: jQuery .each() on a regular array
And here is what that "report writer syntax" produces for output, for those interested. Lots of text redacted...
Last edited by szlamany; Feb 20th, 2021 at 04:59 PM.
-
Feb 22nd, 2021, 10:17 AM
#4
Re: jQuery .each() on a regular array
Is this a question or more of a codebank submission?
-
Feb 22nd, 2021, 10:39 AM
#5
Re: jQuery .each() on a regular array
Do we have a code bank for jQuery?
-
Feb 22nd, 2021, 10:49 AM
#6
Re: jQuery .each() on a regular array
Since jQuery is a JavaScript library, if it is a codebank submission, then it would go in the JavaScript Codebank with the jQuery prefix.
-
Feb 22nd, 2021, 10:52 AM
#7
Re: jQuery .each() on a regular array
Originally Posted by dday9
Since jQuery is a JavaScript library, if it is a codebank submission, then it would go in the JavaScript Codebank with the jQuery prefix.
Could you please move it? Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|