vendredi 22 mai 2015

Passing custom parameters from view to controller

I want to bind a custom attribute (the id of a conversation) to the template and access it from its controller so I can pass it to another controller. How can I do that? Where should I bind it and how to access it from inside the controller? Should I make an interaction with the view of the list and if so how?

Template :

<script type="text/x-handlebars" data-template-name="list">   
{{#each conv in model}}    
    <div class="conversation-content-wrapper" {{action "click"}}>
            <div class="history-message-assigned in-progress-closed" style="display:none;"><p><i class="icon-x"></i>Conversation closed</p></div>
            <div class="history-message-assigned in-progress-assignation" style="display:none;"><p><i class="icon-assign"></i>Conversation assigned</p></div>
            <div class="history-message-assigned in-progress-reopen" style="display:none;"><p><i class="icon-re-opened"></i>Conversation re-opened</p></div>          
        <div class="conversation-history">          
            <div class="conversation-time-history">{{{conv.timeAgoElement}}}</div>
            <div class="conversation-details">
                <span class="unread-numbers" data-badge="2"></span>
                    <input type="checkbox" name="conversations_ids[]" value="{{conv.id}}" />
                     <span class="conversation-name">{{conv.customer.name}}</span>
                     <span class="phone-number">{{conv.customer.cellPhoneNumber}}</span>
                    <p class="conversation-text">{{conv.lastMessage}}</p>
            </div>
        </div>                       
    </div>
{{/each}}     
</script>

Controller :

App.ListController = Ember.ArrayController.extend({

    needs: ['convcenter'],

    queryParams: ['status'],
    status : 'opened',

    actions: {

        click: function(){

        ** this is where I need to access the id property in convid**
        this.get('controllers.convcenter').set('selectedConv', 'convid')


    }

}

});

Thank you.




Aucun commentaire:

Enregistrer un commentaire