Sha256: a7a33237bcad4ccf2d7c4710d77e55063102ee8814b3dc238d1ac53b026f4e4c
Contents?: true
Size: 1.09 KB
Versions: 11
Compression:
Stored size: 1.09 KB
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) -> record_or_records = undefined # 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.push(record) record_or_records = records # Single-Record JSON else if data record_attributes = data record = new LiveRecord.Model.all[args['modelName']](record_attributes) record.create() record_or_records = record args['onLoad'].call(this, record_or_records) if args['onLoad'] ).fail( (jqxhr, textStatus, error) -> args['onError'].call(this, jqxhr, textStatus, error) if args['onError'] )
Version data entries
11 entries across 11 versions & 1 rubygems