HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavascriptMinor

Creating rows from JSON data

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
rowscreatingjsonfromdata

Problem

I am getting data from JSON and then create rows of it:

$.each(data.GetwebMethodResult, function (index, item) {
        $("#TableABC").append(FunABC(item.aID, item.b, item.c, item.d, item.e, item.f));
        });

function FunABC(a, b, c, d, e, f) {
    var row =
        "" +
        "   " +
        "       " +
        "           " + a + "" +
        "       " +
        "   " +
        "";

    return row;
}


Is there any better way of doing it?

Solution

Not really. It hard to optimize something with little logic. You could do this instead:

var row =
    " \
        \
            \
               " + a + " \
            \
        \
    ";


But aside from that looks good!

Code Snippets

var row =
    "<tr class='Row' onclick=\"AnotherUnrelatedFunction('" + a + "' , '" + b + "', '" + c + "', '" + d + "', '" + e + "', '" + f + "')\> \
       <div class='mr'> \
           <td class='mc mci'> \
               <div class='mcit'>" + a + "</div> \
           </td> \
       </div> \
    </tr>";

Context

StackExchange Code Review Q#38822, answer score: 3

Revisions (0)

No revisions yet.