Created
October 4, 2013 18:44
-
-
Save qpfiffer/6830716 to your computer and use it in GitHub Desktop.
ASYNCHRONOUS GODS, HEAR MY CALL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| table.columns().result( | |
| function(columns) { | |
| var field_to_column = {}; | |
| var self = this; | |
| var one_big_promise = _.reduce(columns, function(accum, column) { | |
| return accum.done(function(thing) { | |
| var relevant_field = _.find(fields, function(x) { return x == column.name; }); | |
| accum.done(function(panic) { | |
| endpoint.schema('data_editor').function("get_widget_name_for_path").args({path: column.selector}).row().result( | |
| function(row_obj) { | |
| w.append('<td>'+ widget(row_obj.value("get_widget_name_for_path"), { field: row.field(relevant_field) }) +'</td>'); | |
| } | |
| ); | |
| }); | |
| }); | |
| }, self); | |
| // Take the list of promises returned by the map call above and pass them | |
| // as arguments to $.when: | |
| $.when(one_big_promise).then(function() { | |
| if (row.is_new()) { | |
| w.append('<td><a class="insert">Insert</a></td>'); | |
| w.append('<td><a class="delete">X</a></td>'); | |
| } else { | |
| w.append('<td>' + widget('row_save', { row: row }) + '</td>'); | |
| w.append('<td>' + widget('row_delete', { row: row }) + '</td>'); | |
| } | |
| }); | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment