我有一个下拉列表,它将从表单构建器获取字段,并且我在下拉列表下方有一个textarea。我希望下拉列表中的值进入当前光标位置所在的textarea。它与检测下拉列表中的变化有关。
任何帮助都会非常感激,因为我一直在努力解决这个问题。
define(["jquery", "underscore", "backbone", "text!templates/app/tab-nav-actions.html", "text!templates/app/textbox.html", "text!templates/app/textarea.html", "views/select", "helper/pubsub"],
function($, _, Backbone, _tabNavTemplate, _textboxTemplate, _textareaTemplate,Select, PubSub) {
return Backbone.View.extend({
tagName: "div",
className: "tab-pane col-xs-12 col-sm-12 col-md-12 col-lg-12",
initialize: function() {
this.id = this.options.id.toLowerCase().replace(/\W/g, '');
this.id = this.id;
this.tabNavTemplate = _.template(_tabNavTemplate);
this.textboxTemplate = _.template(_textboxTemplate);
this.textareaTemplate = _.template(_textareaTemplate);
this.select = new Select({
id: this.id + (new Date().getTime() - 2),
collection: this.collection,
className: "col-xs-6 col-sm-6 col-md-5 col-lg-4 col-md-offset-1 col-lg-offset-1"
});
this.drop = new Select({
id: this.id + (new Date().getTime() - 2),
collection: this.collection,
className: "col-xs-6 col-sm-6 col-md-5 col-lg-4 col-md-offset-1 col-lg-offset-1"
});
this.render();
},
render: function() {
$("#actionstabs").append(this.tabNavTemplate({
title: this.options.title,
id: this.id
}));
this.$el.attr("id", this.id);
this.$el.append("<div class='actionsheadingrow col-xs-12 col-sm-12 col-md-12 col-lg-12'><h2>To</h2></div>");
this.$el.append(this.select.render().el);
this.$el.append("<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12'><h2>Subject</h2></div>");
this.$el.append(this.textboxTemplate({
subjectclasses: "col-xs-6 col-sm-6 col-md-5 col-lg-4 col-md-offset-1 col-lg-offset-1",
id: this.id + "subject"
}));
this.$el.append("<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12'><h3>Message</h3></div>");
this.$el.append(this.textareaTemplate({
bodyclasses: "col-xs-6 col-sm-6 col-md-8 col-lg-4 col-md-offset-1 col-lg-offset-1",
id: this.id + "Message"
}));
this.$el.append(this.drop.render().el);
this.$el.appendTo("#actionscontent");
this.delegateEvents();
}
});
drop.onchange = function(){
textareaTemplate.value = textareaTemplate.value + this.append; //to appened
//mytextbox.innerHTML = this.value;
}
});