lib/assets/javascripts/up/flow.js.coffee in upjs-rails-0.3.0 vs lib/assets/javascripts/up/flow.js.coffee in upjs-rails-0.3.2

- old
+ new

@@ -39,10 +39,11 @@ The CSS selector to update. You can also pass a DOM element or jQuery element here, in which case a selector will be inferred from the element's class and ID. @param {String} url The URL to fetch from the server. @param {String} [options.title] + @param {String} [options.method='get'] @param {String|Boolean} [options.history=true] If a `String` is given, it is used as the URL the browser's location bar and history. If omitted or true, the `url` argument will be used. If set to `false`, the history will remain unchanged. @param {String|Boolean} [options.source=true] @@ -56,13 +57,18 @@ selector = if u.presence(selectorOrElement) selectorOrElement else u.createSelectorFromElement($(selectorOrElement)) + if !up.browser.canPushState() && !u.castsToFalse(options.history) + up.browser.loadPage(url, u.only(options, 'method')) + return + u.ajax( url: url, - selector: selector + selector: selector, + u.only(options, 'method') ) .done (html, textStatus, xhr) -> # The server can send us the current path using a header value. # This way we know the actual URL if the server has redirected. if currentLocation = u.locationFromXhr(xhr) @@ -111,10 +117,11 @@ for step in implantSteps(selector, options) $old = # always prefer to replace content in popups or modals u.presence($(".up-popup " + step.selector)) || u.presence($(".up-modal " + step.selector)) || - u.presence($(step.selector)) + u.presence($(step.selector)) || + u.error("Could not find selector (#{step.selector}) in current body HTML") if fragment = htmlElement.querySelector(step.selector) $new = $(fragment) swapElements $old, $new, step.pseudoClass, step.transition, options else u.error("Could not find selector (#{step.selector}) in response (#{html})")