私はレシピモデルを持っています、そしてレシピはたくさんの材料を保存する材料リストコレクションを持っています。
フォーム送信から材料リストに材料を追加するとき、サーバーから「id」を取得する必要があるため、ajaxリクエストを実行し、IDを取得して、モデルに材料を追加しようとしています。
私のcomponentlist.viewには、
初期化:function(){ this.recipe = this.model; }、 get_ingredient:function(ingredient){ var components_id = new MyApp.Models.Ingredient; 成分.url='/components /?ing ='+ encodeURIComponent(ingredient_array [i]); 成分.fetch({ 成功:function(){ this.recipe('add:ingredients'、function(ingredient、ingredientlist){ }); }、 エラー:function(){ new Error({メッセージ: "材料を追加しています"}); } }); }
'get_ingredient'をトリガーする関数は含めませんでした。これは、ajaxが正常に取得されているため、'get_ingredient'をトリガーすることに問題がないためです。
Uncaught TypeError: Property 'recipe' of object [object DOMWindow] is not a function
既存のコードを使用するとエラーが発生します。
このようなことを達成するための最良の方法は何ですか?