我是backbone.js 的初学者。
实际上我正在开发聊天应用程序。
我将 textarea 给用户以输入消息,并且我希望当用户单击发送时,该消息应附加到我指定的上部 div。
使用backbone.js如何实现这一点?请参阅下面的 textarea 代码和提交按钮:
<textarea name="message" cols="20" rows="4" id="usermessage" ></textarea>
<input name="submitmessage" type="submit" id="submitmessage" value="Send" />
请参阅以下代码以获取聊天历史视图:
<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();
}
请检查并帮助我解决这个问题...