[dw-free] Revamp /update
[commit: http://hg.dwscoalition.org/dw-free/rev/d9be734ba42c]
http://bugs.dwscoalition.org/show_bug.cgi?id=2524
Fix syncing of the visible tags to the hidden tag text input.
Patch by
fu.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2524
Fix syncing of the visible tags to the hidden tag text input.
Patch by
Files modified:
- htdocs/js/jquery.autocompletewithunknown.js
--------------------------------------------------------------------------------
diff -r 8c1f8fad1e92 -r d9be734ba42c htdocs/js/jquery.autocompletewithunknown.js
--- a/htdocs/js/jquery.autocompletewithunknown.js Fri Nov 04 12:34:07 2011 +0800
+++ b/htdocs/js/jquery.autocompletewithunknown.js Fri Nov 04 13:52:46 2011 +0800
@@ -1,4 +1,13 @@
(function($) {
+ function _arrayToVal( array, ele ) {
+ var tags_array = [];
+ $.each( array, function(key) {
+ tags_array.push( key );
+ });
+
+ ele.val( tags_array.join(",") );
+ }
+
// this doesn't act on the autocompletewithunknown widget. Instead, it's called on our input field with autocompletion
function _handleComplete(e, ui, $oldElement) {
var self = $(this).data("autocompletewithunknown");
@@ -47,12 +56,7 @@
$("#"+self.options.id+"_count").text(self.options.maxlength);
}
- var tags_array = [];
- $.each( self.tagslist, function(key) {
- tags_array.push( key );
- });
-
- ele.val( tags_array.join(",") );
+ _arrayToVal(self.tagslist, ele)
if ( $.browser.opera ) {
var keyCode = $.ui.keyCode;
@@ -236,6 +240,7 @@
$("span."+self.options.tokenTextClass, self.uiAutocomplete.get(0))
.live("click", function(event) {
delete self.tagslist[$(this).text()];
+ _arrayToVal(self.tagslist, self.element);
var $input = $("<input type='text' />")
.addClass(self.options.tokenTextClass)
.val($(this).text())
@@ -253,6 +258,7 @@
var $token = $(this).closest("."+self.options.tokenClass);
delete self.tagslist[$token.children("."+self.options.tokenTextClass).text()];
+ _arrayToVal(self.tagslist, self.element);
$token.fadeOut(function() {$(this).remove()});
event.preventDefault();
--------------------------------------------------------------------------------
