Advertisement
Guest User

multiselect for jeditable

a guest
May 18th, 2010
998
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             multiSelect: {
  2.                element : function(settings, original) {
  3.                     var select = $('<select multiple size=10/>');
  4.                     $(this).append(select);
  5.                     return(select);
  6.                 },
  7.                 content : function(data, settings, original) {
  8.                     /* If it is string assume it is json. */
  9.                     if (String == data.constructor) {
  10.                         eval ('var json = ' + data);
  11.                     } else {
  12.                     /* Otherwise assume it is a hash already. */
  13.                         var json = data;
  14.                     }
  15.                     for (var key in json) {
  16.                         if (!json.hasOwnProperty(key)) {
  17.                             continue;
  18.                         }
  19.                         if ('selected' == key) {
  20.                             continue;
  21.                         }
  22.                         var option = $('<option />').val(key).append(json[key]);
  23.                         $('select', this).append(option);
  24.                     }
  25.                     /* Loop option again to set selected. IE needed this... */
  26.                     $('select', this).children().each(function() {
  27.                         var option = $(this);
  28.                         $.each(json.selected, function(index, value) {
  29.                             if ( option.val() == value ||
  30.                                 option.text() == $.trim(original.revert)) {
  31.                                 option.attr('selected', 'selected');
  32.                             }
  33.                         })
  34.                     });
  35.                 }//,
  36.                // submitdata : function(value, settings) {
  37.                //     console.log('insubmitdata');
  38.                //     return $('select',this).val();
  39.                // }
  40.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement