From 95fc7167dd9665de4cee593e127beef18f892c6c Mon Sep 17 00:00:00 2001 From: "Jessica B. Hamrick" Date: Thu, 17 Apr 2014 11:06:11 -0400 Subject: [PATCH] Add placeholder to textarea as well as text --- IPython/html/static/widgets/js/widget_string.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/IPython/html/static/widgets/js/widget_string.js b/IPython/html/static/widgets/js/widget_string.js index aa5f98e91..4fe80d4ef 100644 --- a/IPython/html/static/widgets/js/widget_string.js +++ b/IPython/html/static/widgets/js/widget_string.js @@ -71,6 +71,11 @@ define(["widgets/js/widget"], function(WidgetManager){ this.update(); // Set defaults. this.model.on('msg:custom', $.proxy(this._handle_textarea_msg, this)); + this.model.on('change:placeholder', function(model, value, options) { + this.update_placeholder(value); + }, this); + + this.update_placeholder(); }, _handle_textarea_msg: function (content){ @@ -80,6 +85,13 @@ define(["widgets/js/widget"], function(WidgetManager){ } }, + update_placeholder: function(value) { + if (!value) { + value = this.model.get('placeholder'); + } + this.$textbox.attr('placeholder', value); + }, + scroll_to_bottom: function (){ // Scroll the text-area view to the bottom. this.$textbox.scrollTop(this.$textbox[0].scrollHeight);