Sha256: 34b9ff9d9996a49e711dc7e8a6b42d58f1aae0f17357e02b5d375bb33e9d0458
Contents?: true
Size: 990 Bytes
Versions: 7
Compression:
Stored size: 990 Bytes
Contents
LiveRecord.helpers.loadRecords = (args) -> args['modelName'] || throw new Error(':modelName argument required') throw new Error(':modelName is not defined in LiveRecord.Model.all') if LiveRecord.Model.all[args['modelName']] == undefined args['url'] ||= window.location.href $.getJSON( args['url'] ).done( (data) -> # Array JSON if $.isArray(data) records_attributes = data; records = [] for record_attributes in records_attributes record = new LiveRecord.Model.all[args['modelName']](record_attributes); record.create(); records << record # Single-Record JSON else record_attributes = data record = new LiveRecord.Model.all[args['modelName']](record_attributes); record.create(); args['onLoad'].call(this, records) if args['onLoad'] ).fail( (jqxhr, textStatus, error) -> args['onError'].call(this, jqxhr, textStatus, error) if args['onError'] )
Version data entries
7 entries across 7 versions & 1 rubygems