tripal.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Using the closure to map jQuery to $.
  2. (function ($) {
  3. // Store our function as a property of Drupal.behaviors.
  4. Drupal.behaviors.tripal = {
  5. attach: function (context, settings) {
  6. $(".tripal-entity-unattached .field-items").replaceWith('<div class="field-items">Loading... <img src="' + tripal_path + '/theme/images/ajax-loader.gif"></div>');
  7. $(".tripal-entity-unattached").each(function() {
  8. id = $(this).attr('id');
  9. $.ajax({
  10. url: baseurl + '/bio_data/ajax/field_attach/' + id,
  11. dataType: 'json',
  12. type: 'GET',
  13. success: function(data){
  14. var content = data['content'];
  15. var id = data['id'];
  16. $("#" + id + ' .field-items').replaceWith(content);
  17. }
  18. });
  19. });
  20. }
  21. }
  22. })(jQuery);
  23. // Used for ajax update of fields by links in a pager.
  24. function tripal_navigate_field_pager(id, page) {
  25. jQuery(document).ajaxStart(function () {
  26. jQuery('#' + id + '-spinner').show();
  27. }).ajaxComplete(function () {
  28. jQuery('#' + id + '-spinner').hide();
  29. });
  30. jQuery.ajax({
  31. type: "GET",
  32. url: Drupal.settings["basePath"] + "bio_data/ajax/field_attach/" + id,
  33. data: { 'page' : page },
  34. success: function(response) {
  35. jQuery("#" + id + ' .field-items').replaceWith(response['content']);
  36. }
  37. });
  38. }