私はbackbone.jsの初心者です。
実は私はチャットアプリを開発しています。
メッセージを入力するためにユーザーにテキストエリアを与え、ユーザーが送信をクリックしたときに、そのメッセージを指定した上部の div に追加する必要があります。
backbone.jsを使用してこれをどのように達成できますか? テキストエリアと送信ボタンについては、以下のコードを参照してください。
<textarea name="message" cols="20" rows="4" id="usermessage" ></textarea>
<input name="submitmessage" type="submit" id="submitmessage" value="Send" />
chahistory ビューのコードの下を参照してください。
<div id="chatHistory"></div>
backbone.js のみを使用してこれを実現したいと考えています。助けてください....
window.ChatHistoryView = Backbone.View.extend({
initialize: function(){
this.render();
},
render: function(){
// Compile the template using underscore
var template = _.template( $("#chat_History").html(), {} );
// Load the compiled HTML into the Backbone "el"
this.$el.html( template );
},
events: {
// "click input[type=button]": "doSearch"
},
});
window.ChatInputView = Backbone.View.extend({
initialize: function(){
this.render();
},
render: function(){
// Compile the template using underscore
var template = _.template( $("#chat_Input").html(), {} );
// Load the compiled HTML into the Backbone "el"
this.$el.html( template );
},
events: {
"click input[type=submit]": "updateChatHistory"
},
updateChatHistory: function( event ){
this.chatHistoryView.$e1.append();
app.navigate('', true);
window.history.back();
}
これを確認して解決するのを手伝ってください...