[ckan-changes] [okfn/ckan] 5eca7d: [#2292, master, js, bugfix][s]: fix brokenness of mul...

GitHub noreply at github.com
Sat Apr 21 15:16:26 UTC 2012


  Branch: refs/heads/master
  Home:   https://github.com/okfn/ckan
  Commit: 5eca7d5e37c0ef392b768b8b3768b2c3f93448b5
      https://github.com/okfn/ckan/commit/5eca7d5e37c0ef392b768b8b3768b2c3f93448b5
  Author: Rufus Pollock <rufus.pollock at okfn.org>
  Date:   2012-04-21 (Sat, 21 Apr 2012)

  Changed paths:
    M ckan/public/scripts/application.js

  Log Message:
  -----------
  [#2292,master,js,bugfix][s]: fix brokenness of multiple dataset addition in group edit form (fixes #2292).

* Issue was that refactoring of HTML had removed element that auto-complete submit handling was searching for in order to add the hidden input holding dataset id info. Made this more robust (do not search for some other element but add as sibling of auto-complete input element.
* Also did some tidying and prettification of the html we add.


diff --git a/ckan/public/scripts/application.js b/ckan/public/scripts/application.js
index 995e703..d94bbd4 100644
--- a/ckan/public/scripts/application.js
+++ b/ckan/public/scripts/application.js
@@ -958,7 +958,6 @@ CKAN.Utils = function($, my) {
       , select: function(event, ui) {
         var input_box = $(this);
         input_box.val('');
-        var parent_dd = input_box.parent('dd');
         var old_name = input_box.attr('name');
         var field_name_regex = /^(\S+)__(\d+)__(\S+)$/;
         var split = old_name.match(field_name_regex);
@@ -967,10 +966,15 @@ CKAN.Utils = function($, my) {
 
         input_box.attr('name', new_name);
         input_box.attr('id', new_name);
-
-        parent_dd.before(
-          '<input type="hidden" name="' + old_name + '" value="' + ui.item.value + '">' + '<dd>' + ui.item.label + '</dd>'
-        );
+        
+        var $new = $('<div class="ckan-dataset-to-add"><p></p></div>');
+        $new.append($('<input type="hidden" />').attr('name', old_name).val(ui.item.value));
+        $new.append('<i class="icon-plus-sign"></i> ');
+        $new.append(ui.item.label);
+        input_box.after($new);
+
+        // prevent setting value in autocomplete box
+        return false;
       }
     });
   };


================================================================



More information about the ckan-changes mailing list