Jquery Dynamically Create Table/tr/td Or Etc And Append Attributes
Test1 | LINK&Solution 1:Here's a simplified example:
Wrap the row portion in a loop, replace with variables and it's at least easier to maintain/read in my opinion, but I'm used to jQuery, so your mileage may vary, just an option. A side note, since this is using Solution 2:Can you make a "template" out of your string? If yes, then store it in a "constant" variable (e.g. defined in global scope), containing placeholders for actual variables, like So, you would have code like this:
You would then use the string.format implementation as per this answer: Equivalent of String.format in jQuery Solution 3:You could create a StringBuilder, much like the one in C#. Here's a snippet took from Telerik Extensions for ASP.NET MVC:
This way, you can have the following code:
The benefit of this approach is that you'll have fast concatenation (array joins perform better under IE6), and you could extend the object with other useful function (say, Solution 4:Or you could instead of concatenating strings together so make use of the array.join function.
Solution 5:
|
Post a Comment for "Jquery Dynamically Create Table/tr/td Or Etc And Append Attributes"