Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. $("#ddlGrouped").editable("url", {
  2. type: 'select',
  3. submit: 'OK',
  4. data: {
  5. 'Swedish Cars' : { 'volvo': 'Volvo', 'saab': 'Saab'},
  6. 'German Cars' : { 'mercedes': 'Mercedes', 'audi': 'Audi'}
  7. }
  8. })
  9.  
  10. select: {
  11. element: function (settings, original) {
  12. var select = $('<select />');
  13. $(this).append(select);
  14. return (select);
  15. },
  16. content: function (data, settings, original) {
  17. /* If it is string assume it is json. */
  18. if (String == data.constructor) {
  19. eval('var json = ' + data);
  20. } else {
  21. /* Otherwise assume it is a hash already. */
  22. var json = data;
  23. }
  24. for (var key in json) {
  25. if (!json.hasOwnProperty(key)) {
  26. continue;
  27. }
  28. if ('selected' == key) {
  29. continue;
  30. }
  31. var option = $('<option />').val(key).append(json[key]);
  32. $('select', this).append(option);
  33. }
  34. /* Loop option again to set selected. IE needed this... */
  35. $('select', this).children().each(function () {
  36. if ($(this).val() == json['selected'] ||
  37. $(this).text() == $.trim(original.revert)) {
  38. $(this).attr('selected', 'selected');
  39. }
  40. });
  41. }
  42. }
  43.  
  44. selectactioner: {
  45. element : function(settings, original) {
  46. var select = $('<select />');
  47. $(this).append(select);
  48. return(select);
  49.  
  50.  
  51. },
  52. content : function(data, settings, original) {
  53.  
  54. var obj = jQuery.parseJSON(data);
  55. var json = obj.attendees;
  56. var json2 = obj.nonattendees;
  57.  
  58. var optgroup = $('<optgroup />');
  59. optgroup.attr('label', 'Meeting Attendees');
  60. $('select', this).append(optgroup);
  61.  
  62. for (var key in json) {
  63. if (!json.hasOwnProperty(key)) {
  64. continue;
  65. }
  66. if ('selected' == key) {
  67. continue;
  68. }
  69. var option = $('<option />').val(key).append(json[key]);
  70. $('select', this).append(option);
  71. }
  72. /* Loop option again to set selected. IE needed this... */
  73. $('select', this).children().each(function() {
  74. if ($(this).val() == json['selected'] ||
  75. $(this).text() == $.trim(original.revert)) {
  76. $(this).attr('selected', 'selected');
  77. }
  78. });
  79.  
  80.  
  81.  
  82.  
  83. var optgroup = $('<optgroup />');
  84. optgroup.attr('label', 'Other Users');
  85. $('select', this).append(optgroup);
  86.  
  87. for (var key in json2) {
  88. if (!json2.hasOwnProperty(key)) {
  89. continue;
  90. }
  91. if ('selected' == key) {
  92. continue;
  93. }
  94. var option = $('<option />').val(key).append(json2[key]);
  95. $('select', this).append(option);
  96. }
  97. /* Loop option again to set selected. IE needed this... */
  98. $('select', this).children().each(function() {
  99. if ($(this).val() == json2['selected'] ||
  100. $(this).text() == $.trim(original.revert)) {
  101. $(this).attr('selected', 'selected');
  102. }
  103. });
  104.  
  105.  
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement