javascript - Ember - Need to add/delete an item in the model -


I have a list of items that have separated on the basis of different values ​​(today, tomorrow, first) . When an element is added / removed, the template should be updated within the specific partition values.

Template:

  & lt; Ul & gt; {{Item in model}} {{#if item.split}} & lt; Li class = "value" & gt; {{Item.Value}} & lt; / Li & gt; {{Else}} & lt; Li & gt; {{Item.name}} & amp; Nbsp; & Amp; Nbsp; & Lt; Span {{Action 'Remove' item}} & gt; X & lt; / Span & gt; & Lt; / Li & gt; {{/ If}} {{/ each}} & lt; / Ul & gt; & Lt; Button {{action 'addToday'}} & gt; Today's object & lt; / Button & gt; & Lt; Button {{action 'addyesterday'}} & gt; Tomorrow's object & lt; / Button & gt; App.js:  
  App.IndexRoute = Ember.Route.extend ({model: function () {var temp_obj = [{'value '' Today ',' division ': true}, {' name ':' Google ',' split ': false}, {' value ':' nowadays', 'division': true}, {'name' '' Stackoverflow '' 'Split': false;] Return back temp_obj;} Actions: {delete: function (obje) {var self = this; self. Gat ('controller'). Remove object (obz);} addToday: Function () {var self = this; var obj = Ember.Object.create ({'Name': 'Today Object', 'Split': false}); self.get ('Controller'). UnshiftObject (obj); }, Add tomorrow: function () {var self = this; var obj = Ember.Object.create ( {'Name': 'Tomorrow object', 'division': wrong}); self.get ('controller'). UnshiftObject (OBJ);}}});  

Here,

  1. Today and the split value needs to be removed, when there are no items between today and tomorrow, similarly yesterday and earlier.
  2. If I do not have any item after tomorrow, then tomorrow's price will not appear.
  3. If there is no item in today's partition value, and when I add a new item, it should be updated with Split Value today.

JSBin demo


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -