私はjqueryが初めてです。質問がばかげていることは知っていますが、ここでいくつかの概念が欠けています。問題は次のとおりです。
$("input.integers").each(function(index) {
console.log("----");
console.log($(this).attr('id') + " " + $(this).val());
console.log($(this).attr('id') + " " + $("#"+$(this).attr('id')).val());
// the next log is here just to show a direct selection. I'm concerned about the two logs above this one
console.log($("#myId").attr('id'), $("#myId").val());
that.setModelData($(this).attr('id'), $(this).val());
});
出力は次のとおりです。
PhantomJS 1.6 (Linux) LOG: '----'
PhantomJS 1.6 (Linux): Executed 61 of 90
PhantomJS 1.6 (Linux) LOG: 'myId '
PhantomJS 1.6 (Linux): Executed 61 of 90
PhantomJS 1.6 (Linux) LOG: 'myId 123'
PhantomJS 1.6 (Linux): Executed 61 of 90
PhantomJS 1.6 (Linux) LOG: [ 'myId', '123' ]
タグが入力されます。$(this).val()
なぜ空で$("#"+$(this).attr('id')).val()
、正しい値が含まれているのでしょうか?
アップデート:
カルマ テスト:
it('the model must be updated', function(){
$("#myId").val("123");
$("#save-process").click();
server.respond();
expect(fdtView.model.get('myId')).toBe("123");
});
フィクスチャ:
<input id="myId" name="myId"
class="integers" type="text" />