2015-01-09 87 views
0

將引導警報消息作爲一個燼組件(它們顯示成功錯誤警告消息...)。我怎樣才能在事件中插入消息?可以說,表單驗證不成功,我想傳遞一個信息與如下因素組成:使用javascript插入組件

{{alert-mes message="The passwords must match" type="error"}} 

回答

1

Embner具有雙向綁定,所以你並不需要通過不同的消息每次,而不是你可以有一個屬性的改變控制器,和你的組件聽的變化:

// controller.js 

showModal: false, 
message: null, 
actions: { 
    somethingHapened: function() { 
    this.set('message', 'The passwords must match'); 
    this.set('showModal', true); 
    } 
} 

// template 
{{alert-mes message=message type="error" show=showModal}} 

// component 

onShowModal: function() { 
    if (this.get('show')) { 
    // display the modal somehow 
    // this.$().show(this.get('message')); 
    } else { 
    // hide the modal 
    } 
}.observes('show') 
+0

我知道的是,代碼只是一個例子,我想知道是否有可能以簡單的鬍子像這樣的東西追加:$('#someDiv')。html('{{block-mes}}'); 但是你幫了我夠了,我可以跟你給我的東西合作,謝謝 –