mercredi 27 juillet 2016

delete multiple records on EmberJS using

I would like to have an action that prints all the selected check-boxes on my table to the console.

in my controller I have

removedSelected: function() { let selected = this.filterBy('isSelected', true); console.log(selected); }

in my template file I have

I have setup my controller to filter all the records that are "isSelected" in the table by using input helper on ember.

I am getting an error on the console which states this.filterBy is not a function

Do i need to setup an array to handle this first?

Below is more of the code for a better picture.

Thanks!

// templates/warranty/index.hbs

<div class="container">
<h4>List</h4>
<div class="row">
    <div class="col-sm-3">
        <div class="control-group">
            New Claim
            <button class="btn btn-primary btn-sm" >Select</button>
            <button class="btn btn-danger btn-sm">Delete Selected</button>
        </div>
    </div>
<div class="container">
    <table class="table table-striped table-hover ">
        <thead>
            <tr>
                <th>Select</th>
                <th>Action</th>
                <th>Claim ID</th>
                <th>Claim Status</th>
                <th>Serial Number</th>
                <th>Issue Description</th>
            </tr>
        </thead>
        <tbody>
            
                <tr>
                    
                    <td>Edit<button class="btn btn-danger btn-xs" >Delete</button></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            
        </tbody>
    </table> 
</div>
</div>

// app/controllers/warranty/index.js

import Ember from 'ember';
export default Ember.Controller.extend({

actions: {
    toggleMultiple() {
        this.toggleProperty('canDeleteMultiple');
    },

    removedSelected: function() {
        let selected = this.filterBy('isSelected', true);
        console.log(selected);
    }
}
});




Aucun commentaire:

Enregistrer un commentaire