Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Change element position in model on click?

$
0
0

@GregWeb wrote:

I’m making a simple todo list and this one has stumped me completely. When I click on a task’s checkmark, I’d like for that element in the model to be moved to the bottom of the list. I found NO way to do this. THe change needs to be persisted to a firebase backend, or localStorage if I decide to swap out the firebase adapter with a localStorage adapter.

I tried something naive like:

 {{#each model as |task index|}}
    <p {{action 'toggleTask' task task.isDone index}}>Some el</p>
 {{/each}}

controller.js//
      toggleTask(task, prop, i){
          task.set(i, 0);
          task.toggleProperty(prop);
          task.save();
        },

This doesn’t throw an error or anything, nothing happens. I tried a bunch of other ember and native javascript methods but nothing works. Haven’t found anything about this online. btw aside from trying to change the index of the elemtn the other two methods ni toggleTask() work fine

Posts: 8

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles