버튼으로 disabled 속성을 바인드하면 일회용으로 당신이 reusabl를 원하는 경우 한 번
그것을 클릭 한 후 같은 너무
<button {{action go}} {{bind-attr disabled=actionPerformed}}>
후 다음 버튼이 비활성화 될 것입니다
var FooController = Ember.ObjectController.extend({
actionPerformed: false,
actions: {
go: function() {
this.set("actionPerformed", true);
console.log("done!");
}
}
});
같은 컨트롤러를 설정 전자 구성 요소 나는 회 전자 버튼을
http://emberjs.com/guides/cookbook/helpers_and_components/spin_button_for_asynchronous_actions/에서 빌려서 필요에 따라 조정할 것입니다.
그래서 JS는 구성 요소에 대한 템플릿
<script type='text/x-handlebars' id='components/spin-button'>
<button {{bind-attr id=id}} {{action 'showLoading'}}>
{{#if isLoading}}
<img src="http://i639.photobucket.com/albums/uu116/pksjce/spiffygif_18x18.gif"></img>
{{else}}
{{buttonText}}
{{/if}}
</button>
</script>
것
window.SpinEg = Ember.Application.create({});
SpinEg.ApplicationController = Ember.Controller.extend({
isLoading:false,
buttonText:"Submit",
actions:{
saveData:function(){
var self = this;
var saveTime = Ember.run.later(function(){
self.set('isLoading', false);
}, 1000);
}
}
});
SpinEg.SpinButtonComponent = Ember.Component.extend({
classNames: ['button'],
buttonText:"Save",
isLoading:false,
actions:{
showLoading:function(){
if(!this.get('isLoading')){
this.set('isLoading', true);
this.sendAction('action');
}
}
}
});
의 라인을 따라 것입니다 당신이
표시 버튼을 필요로하는 곳에 당신은 다음과 다음 것
<script type='text/x-handlebars' id='application'>
{{spin-button id="forapplication" isLoading = isLoading buttonText=buttonText action='saveData'}}
</script>
아마도 이것이 필요한 것일 수 있습니다. https://github.com/dockyard/ember-cli-async-button – blessenm