I have a 5x5, table in HTML, that is, each tr has 5 td's, and each td has one input field, which i want to parse for value, also each td has data attributes for data-row and data-column. this is what i have come up with, but it's buggy, how do i do it?
tds = $('td')
marker = 0
thisSet = []
table = []
for td in tds
thisRow = parseInt($(td).attr('data-row'))
if marker == thisRow
rc = "#{$(td).attr('data-row')}-#{$(td).attr('data-column')}"
thisSet.push ({data: rc})
console.log "marker:#{marker}, thisRow:#{thisRow}"
else
rc = "#{$(td).attr('data-row')}-#{$(td).attr('data-column')}"
thisSet.push ({data: rc})
marker = thisRow
console.log "marker:#{marker}, thisRow:#{thisRow}"
table.push thisSet
thisSet = []
console.log table
console.log _.flatten(table).length
UPDATE: ok, worked a little more on it, now i have 4 rows parsed, not the 5th row, theres something missing, but 4 rows parse fine.
tds = $('td')
currentRow = 0
thisSet = []
table = []
for td in tds
thisRow = parseInt($(td).attr('data-row'))
rc = "#{$(td).attr('data-row')}-#{$(td).attr('data-column')}"
if currentRow != thisRow
table.push thisSet
thisSet = []
thisSet.push ({data: rc})
currentRow = thisRow
else
thisSet.push ({data: rc})
console.log table
console.log _.flatten(table).length
coffeescripttag"[row]-[column]"?