Thursday, 15 May 2014

ruby on rails - Moment.js issue in Ember application on Safari -



ruby on rails - Moment.js issue in Ember application on Safari -

i started using moment.js in ember/rails application. works great on chrome, i'm running issue on safari date shows as: "undefined nan/nan/0nan". double-checked on console, , sure plenty i'm getting "invalid date" error message. think problem coming how dates formatted in ember ds models, since json returns valid date string both browsers. have workaround this?

html: {{#each exam in model}} <tr> <td> {{#link-to 'exam' exam}}{{date exam.examdate}}{{/link-to}} </td> </tr> {{/each}} javascript: ember.handlebars.registerboundhelper "date", (date) -> moment(date).format('ddd l, h:mm a') app.exam = ds.model.extend( examdate: ds.attr('date') ) app.applicationstore = ds.store.extend( revision: 12 adapter: app.applicationadapter ) app.applicationadapter = ds.activemodeladapter.extend( namespace: 'api/v1' ) json: { "exam_date":"2012-12-12 00:00:00" }

edit: if else runs problem, solved issue changing ds.attr("date") ds.attr("string").

i'm going have guess bit, since don't want go alpha releases of ember data, bet it's related how server responding.

if this.store.find('exam') expecting result this

{ exams:[ { "exam_date":"2014-06-12t14:40:25-07:00", "id":2 }, { "exam_date":"2014-06-12t14:40:25-07:00", "id":3 }, .... ] }

i'd recommend upgrading version of ember info @ to the lowest degree 1.0 beta+. can read more changes here: https://github.com/emberjs/data/blob/master/transition.md

i set illustration of app: http://emberjs.jsbin.com/oxidivu/680/edit

ruby-on-rails ember.js safari momentjs

No comments:

Post a Comment