Show More
@@ -192,7 +192,7 define([ | |||||
192 | var disabled = this.model.get('disabled'); |
|
192 | var disabled = this.model.get('disabled'); | |
193 | var that = this; |
|
193 | var that = this; | |
194 | _.each(items, function(item, index) { |
|
194 | _.each(items, function(item, index) { | |
195 | var item_query = ' :input[value="' + item + '"]'; |
|
195 | var item_query = ' :input[data-value="' + encodeURIComponent(item) + '"]'; | |
196 | if (that.$el.find(item_query).length === 0) { |
|
196 | if (that.$el.find(item_query).length === 0) { | |
197 | var $label = $('<label />') |
|
197 | var $label = $('<label />') | |
198 | .addClass('radio') |
|
198 | .addClass('radio') | |
@@ -203,6 +203,7 define([ | |||||
203 | .attr('type', 'radio') |
|
203 | .attr('type', 'radio') | |
204 | .addClass(that.model) |
|
204 | .addClass(that.model) | |
205 | .val(item) |
|
205 | .val(item) | |
|
206 | .attr('data-value', encodeURIComponent(item)) | |||
206 | .prependTo($label) |
|
207 | .prependTo($label) | |
207 | .on('click', $.proxy(that.handle_click, that)); |
|
208 | .on('click', $.proxy(that.handle_click, that)); | |
208 | } |
|
209 | } | |
@@ -310,12 +311,12 define([ | |||||
310 | var that = this; |
|
311 | var that = this; | |
311 | var item_html; |
|
312 | var item_html; | |
312 | _.each(items, function(item, index) { |
|
313 | _.each(items, function(item, index) { | |
313 | if (item.trim().length == 0) { |
|
314 | if (item.trim().length === 0) { | |
314 | item_html = " "; |
|
315 | item_html = " "; | |
315 | } else { |
|
316 | } else { | |
316 | item_html = utils.escape_html(item); |
|
317 | item_html = utils.escape_html(item); | |
317 | } |
|
318 | } | |
318 | var item_query = '[data-value="' + item + '"]'; |
|
319 | var item_query = '[data-value="' + encodeURIComponent(item) + '"]'; | |
319 | var $item_element = that.$buttongroup.find(item_query); |
|
320 | var $item_element = that.$buttongroup.find(item_query); | |
320 | if (!$item_element.length) { |
|
321 | if (!$item_element.length) { | |
321 | $item_element = $('<button/>') |
|
322 | $item_element = $('<button/>') | |
@@ -323,7 +324,8 define([ | |||||
323 | .addClass('btn btn-default') |
|
324 | .addClass('btn btn-default') | |
324 | .html(item_html) |
|
325 | .html(item_html) | |
325 | .appendTo(that.$buttongroup) |
|
326 | .appendTo(that.$buttongroup) | |
326 | .attr('data-value', item) |
|
327 | .attr('data-value', encodeURIComponent(item)) | |
|
328 | .attr('value', item) | |||
327 | .on('click', $.proxy(that.handle_click, that)); |
|
329 | .on('click', $.proxy(that.handle_click, that)); | |
328 | that.update_style_traits($item_element); |
|
330 | that.update_style_traits($item_element); | |
329 | } |
|
331 | } | |
@@ -337,7 +339,7 define([ | |||||
337 |
|
339 | |||
338 | // Remove items that no longer exist. |
|
340 | // Remove items that no longer exist. | |
339 | this.$buttongroup.find('button').each(function(i, obj) { |
|
341 | this.$buttongroup.find('button').each(function(i, obj) { | |
340 |
var value = $(obj). |
|
342 | var value = $(obj).attr('value'); | |
341 | var found = false; |
|
343 | var found = false; | |
342 | _.each(items, function(item, index) { |
|
344 | _.each(items, function(item, index) { | |
343 | if (item == value) { |
|
345 | if (item == value) { | |
@@ -409,7 +411,7 define([ | |||||
409 | * Calling model.set will trigger all of the other views of the |
|
411 | * Calling model.set will trigger all of the other views of the | |
410 | * model to update. |
|
412 | * model to update. | |
411 | */ |
|
413 | */ | |
412 |
this.model.set('value_name', $(e.target). |
|
414 | this.model.set('value_name', $(e.target).attr('value'), {updated_view: this}); | |
413 | this.touch(); |
|
415 | this.touch(); | |
414 | }, |
|
416 | }, | |
415 | }); |
|
417 | }); | |
@@ -445,10 +447,11 define([ | |||||
445 | var items = this.model.get('_value_names'); |
|
447 | var items = this.model.get('_value_names'); | |
446 | var that = this; |
|
448 | var that = this; | |
447 | _.each(items, function(item, index) { |
|
449 | _.each(items, function(item, index) { | |
448 |
var item_query = 'option[valu |
|
450 | var item_query = 'option[data-value="' + encodeURIComponent(item) + '"]'; | |
449 | if (that.$listbox.find(item_query).length === 0) { |
|
451 | if (that.$listbox.find(item_query).length === 0) { | |
450 | $('<option />') |
|
452 | $('<option />') | |
451 | .text(item) |
|
453 | .text(item) | |
|
454 | .attr('data-value', encodeURIComponent(item)) | |||
452 | .attr('value_name', item) |
|
455 | .attr('value_name', item) | |
453 | .appendTo(that.$listbox) |
|
456 | .appendTo(that.$listbox) | |
454 | .on('click', $.proxy(that.handle_click, that)); |
|
457 | .on('click', $.proxy(that.handle_click, that)); |
General Comments 0
You need to be logged in to leave comments.
Login now