Show More
@@ -58,7 +58,7 define(["notebook/js/widgets/widget"], function(WidgetManager){ | |||
|
58 | 58 | |
|
59 | 59 | if (options === undefined || options.updated_view != this) { |
|
60 | 60 | var selected_item_text = this.model.get('value_name'); |
|
61 | if (selected_item_text.length === 0) { | |
|
61 | if (selected_item_text.trim().length === 0) { | |
|
62 | 62 | this.$droplabel.html(" "); |
|
63 | 63 | } else { |
|
64 | 64 | this.$droplabel.text(selected_item_text); |
@@ -233,18 +233,24 define(["notebook/js/widgets/widget"], function(WidgetManager){ | |||
|
233 | 233 | var items = this.model.get('value_names'); |
|
234 | 234 | var disabled = this.model.get('disabled'); |
|
235 | 235 | var that = this; |
|
236 | var item_html; | |
|
236 | 237 | _.each(items, function(item, index) { |
|
237 | var item_query = ' :contains("' + item + '")'; | |
|
238 | if (that.$buttongroup.find(item_query).length === 0) { | |
|
239 |
|
|
|
238 | if (item.trim().length == 0) { | |
|
239 | item_html = " "; | |
|
240 | } else { | |
|
241 | item_html = IPython.utils.escape_html(item); | |
|
242 | } | |
|
243 | var item_query = '[data-value="' + item + '"]'; | |
|
244 | var $item_element = that.$buttongroup.find(item_query); | |
|
245 | if (!$item_element.length) { | |
|
246 | $item_element = $('<button/>') | |
|
240 | 247 | .attr('type', 'button') |
|
241 | 248 | .addClass('btn') |
|
242 |
. |
|
|
249 | .html(item_html) | |
|
243 | 250 | .appendTo(that.$buttongroup) |
|
251 | .attr('data-value', item) | |
|
244 | 252 | .on('click', $.proxy(that.handle_click, that)); |
|
245 | 253 | } |
|
246 | ||
|
247 | var $item_element = that.$buttongroup.find(item_query); | |
|
248 | 254 | if (that.model.get('value_name') == item) { |
|
249 | 255 | $item_element.addClass('active'); |
|
250 | 256 | } else { |
@@ -255,7 +261,7 define(["notebook/js/widgets/widget"], function(WidgetManager){ | |||
|
255 | 261 | |
|
256 | 262 | // Remove items that no longer exist. |
|
257 | 263 | this.$buttongroup.find('button').each(function(i, obj) { |
|
258 |
var value = $(obj). |
|
|
264 | var value = $(obj).data('value'); | |
|
259 | 265 | var found = false; |
|
260 | 266 | _.each(items, function(item, index) { |
|
261 | 267 | if (item == value) { |
@@ -285,7 +291,7 define(["notebook/js/widgets/widget"], function(WidgetManager){ | |||
|
285 | 291 | |
|
286 | 292 | // Calling model.set will trigger all of the other views of the |
|
287 | 293 | // model to update. |
|
288 |
this.model.set('value_name', $(e.target). |
|
|
294 | this.model.set('value_name', $(e.target).data('value'), {updated_view: this}); | |
|
289 | 295 | this.touch(); |
|
290 | 296 | }, |
|
291 | 297 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now