0
간단한 입력 &을 함수를 통해 실행하고 그 함수의 결과를 같은 템플릿의 다른 위치에 표시하려고합니다. 함수의 결과를 표시하기 위해 바인딩을 연결하는 위치를 파악할 수 없습니다. 입력 된 값에 대한 계산을 실행하고 결과를 {{suggestedGrams}}
으로 푸시하려고합니다. 이 템플릿에 대해 생성 된보기를 사용하고 있습니다. 나는 분명 뭔가가 있다고 생각입력이 제출 될 때 함수 실행
템플릿
<script type="text/x-handlebars" data-template-name="brew">
{{input type="text" id="start-brew" placeholder="Enter a number, e.g: 16" name=id value=submittedOunces action="startBrew"}}
<p>We recommend using {{suggestedGrams}} grams of coffee for {{ounces}} oz. in a {{id}}.</p>
</script>
컨트롤러
App.BrewController = Ember.ObjectController.extend({
submittedOunces: "",
// updates the {{ounces}} binding with value typed in input
ounces: function() {
if (this.submittedOunces.length < 1) {
return "";
} else {
return this.get("submittedOunces");
}
}.property("submittedOunces"),
actions: {
startBrew: function() {
// other logic is here to show hidden div's
}
}
});
,하지만 난 완전히 새로운 해요 : 여기
내가있어 무엇 Ember에게 알려 줘서 내가 찾는 것을 찾기 위해 적당한 용어를 찾는 것은 어렵다. 어떤 도움을 주시면 감사하겠습니다.
답을 얻기 위해이 주제를 읽으십시오 : 여기 내 마지막 코드입니다 http://stackoverflow.com/questions/18309544/how-do-i-handle-form-submission-in-ember-js – MrBoolean
네가하려는 일을 정확히 모르겠다. 'suggestedGrams : "test"를 컨트롤러에 추가하면 그게 나타나나요? 당신은 어딘가에'suggestgrams '을 caclulate하려고합니까? – claptimes
@claptimes - 예. 미안하지만 내 설명이 분명하지 않다면. 내가 간결하게하기 위해 몇 가지 코드를 꺼냈다. 본질적으로 나는 입력 값을 입력 받아이를 수치 연산 ("value entered"* 2와 같은 것)을하고 싶습니다. – motoxer4533