Skip to content

Commit

Permalink
Tokenize2 / ordered lists mangled when setting the same content twice,
Browse files Browse the repository at this point in the history
  • Loading branch information
AdSchellevis committed Sep 25, 2019
1 parent 680bd22 commit a4217d8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/opnsense/www/js/opnsense.js
Expand Up @@ -136,6 +136,12 @@ function setFormData(parent,data) {
if (targetNode.is("select")) {
// handle select boxes
targetNode.empty(); // flush
if (targetNode.hasClass("tokenize")) {
// when setting the same content twice to a widget, tokenize2 sorting mixes up.
// Ideally formatTokenizersUI() or tokenize2 should handle this better, but for now
// this seems like the only fix that actually works.
targetNode.tokenize2().trigger('tokenize:clear');
}
$.each(node[keypart],function(indxItem, keyItem){
var opt = $("<option>").val(htmlDecode(indxItem)).text(keyItem["value"]);
if (keyItem["selected"] != "0") {
Expand Down

3 comments on commit a4217d8

@fichtner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah oO

@AdSchellevis
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a proper bug report.... this would have been the obvious place to look in 15 minutes. It's still annoying though, tokenize2 needs quite some "patches" for us unfortunately

@fichtner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sorting isn't widely used / common practice it seems. still, nice catch

Please sign in to comment.