tripal.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. function tripal_navigate_field_pager(id, page) {
  24. jQuery(document).ajaxStart(function () {
  25. jQuery('#' + id + '-spinner').show();
  26. }).ajaxComplete(function () {
  27. jQuery('#' + id + '-spinner').hide();
  28. });
  29. jQuery.ajax({
  30. type: "GET",
  31. url: Drupal.settings["basePath"] + "bio_data/ajax/field_attach/" + id,
  32. data: { 'page' : page },
  33. success: function(response) {
  34. jQuery("#" + id + ' .field-items').replaceWith(response['content']);
  35. }
  36. });
  37. }