Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal showPageByHref() not calling callback functions (custom fix inside) #524

Open
tegola opened this issue Mar 27, 2015 · 0 comments
Open

Comments

@tegola
Copy link

tegola commented Mar 27, 2015

Internal showPageByHref function doesn't take into account the callback parameter:

For example, this callback found on jQT itself won't work:

showPageByHref(params.$el.attr("href"), {
  animation: animation,
  callback: function() {
    params.$el.removeClass("loading");
    return setTimeout(function() {
      return params.$el.removeClass('active');
    }, 250);
  },
  $referrer: params.$el
});

Here's the original showPageByHref with my fix applied (again, I'm not familiar with CoffeeScript, so can't do a pull request:

showPageByHref = (function(_this) {
  return function(href, options) {
    options = $.extend({}, {
      data: null,
      method: "GET",
      animation: null,
      $referrer: null
    }, options);
    if (href.charAt(0) !== '#') {
      return $.ajax({
        url: href,
        data: options.data,
        type: options.method,
        success: function(data) {
          var firstPage;
          firstPage = insertPages(data, options.animation);
          if (firstPage) {
            if (options.method === "GET" && _this.settings.cacheGetRequests === true && options.$referrer) {
              return options.$referrer.attr("href", "#" + firstPage.attr("id"));
            }
          }
          // FIX START         
          if (options.callback && typeof options.callback === "function") {
            options.callback.call();
          }
          // FIX END
        },
        error: function(data) {
          if (options.$referrer) {
            return options.$referrer.removeClass('active');
          }
        }
      });
    } else {
      if (options.$referrer) {
        return options.$referrer.removeClass('active');
      }
    }
  };
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant