重力视图 Ajax Link

GravityView Ajax Link

我有一个用 GravityView 创建的 table,我想用 Ajax 实现单个条目 link,这样页面就不会刷新,而 URL 会刷新不变。 这样的事情可能吗?

enter image description here

感谢使用GravityView! Zack,创始人。

我们将在今年晚些时候添加此功能。如果您再等几个月,它就会准备就绪!

您可以使用 jQuery.load 方法加载单个入口页面。

您需要传递页面的 URL,在这种情况下,我试图获取另一个页面上的内容,该页面的 URL 位于锚点 link table,在你的例子中是 link 字段。

所以我给.load方法URL+我需要显示的内容所在的手风琴的id,以及一个回调函数。

我是怎么做到的。

jQuery( document ).ready(function($) {
  // select the div where you want to display content
  var $loadedContent = $('#fl-accordion-5c450fd66133e-panel-0');
  // register an event, get the click event of the link
  $(document).on('click','.gv-field-3-date_created a', function(event) {
      //stop the link form opening
      event.preventDefault();
      //get URL from the href attribute of the anchor link
      var $url = $(this).attr("href");
      // send the request and get the response, In my case I am trying to show the content inside a accordian, so i have taken its ID and added that with URL
      $loadedContent.load($url+' #fl-accordion-5c450fd66133e-panel-0', completeFunction);
      return false;
  });

  function completeFunction(responseText, textStatus, request) {
      if(textStatus == 'error') {
          // show a relevant message
          $loadedContent.text('An error occurred during your request: ' +  request.status + ' ' + request.statusText);
      } 
  }
  });

只需添加您的 类,即可完成工作。