Permalink
Browse files

Updating docs wrt deprecated api

  • Loading branch information...
1 parent 0a3757e commit 474ab86ba483ca5ebe1a68188ab0c387122fb938 @finnsson committed Mar 23, 2013
View
@@ -1411,23 +1411,6 @@
}
};
- /**
- *
- * @param {String/Object} options
- */
- pager.startHashChange = function (options) {
- var id = typeof options === 'string' ? options : null;
- if (id) {
- window.location.hash = pager.Href.hash + id;
- }
- $(window).hashchange(function () {
- goTo(window.location.hash);
- });
- if(!options || !options.noGo) {
- $(window).hashchange();
- }
- };
-
/**
* This is the hash-based start-method.
*
@@ -13,6 +13,16 @@ <h1>API</h1>
<code>page: {}</code>-configuration,
and <code>pager.Page</code>-class.
</p>
+
+ <div class="alert">
+ <h3>There are a number of breaking changes in 1.0rc1</h3>
+ <ul>
+ <li><code>navigationFailed</code> is now called <code>onNoMatch</code> and is a <code>$.Callbacks()</code>.</li>
+ <li><code>startHashChange</code> is removed. <code>start</code> should be used instead.</li>
+ <li>All events/callbacks get a data-object <code>{page:}</code>.</li>
+ <li>Removed <code>page-href5</code> and <code>page-hash</code>. Only use <code>page-href</code>.</li>
+ </ul>
+ </div>
</header>
<ul class="nav nav-tabs" data-bind="foreach: $page.children">
@@ -267,7 +267,7 @@ <h3><code class="code-large">loader : Function(Page,Node)</code></h3>
</div>
-<h3><code class="code-large">navigationFailed : Observable({page:Page,route:String[])</code></h3>
+<h3><code class="code-large">onNoMatch : {page:Page,route:String[]}</code></h3>
<div class="form-actions">
@@ -1,7 +1,8 @@
<h3><code class="code-large">start([id: String])</code></h3>
<p class="p">
- This method will start to listen to hashchange-events. Works only for newer browsers (not IE7).
+ This method will start to listen to hashchange-events. Works only for newer browsers (not IE7/IE8).
+ Include <code>jQuery Hashchange</code> plugin to get support for IE7/IE8.
<br/>
This method should be called after <code>ko.applyBindings(...)</code>.
<br/>
@@ -21,30 +22,6 @@ <h3><code class="code-large">start([id: String])</code></h3>
</pre>
-<h3><code class="code-large">startHashChange([id: String])</code></h3>
-
-<p class="p">
- This method will start to listen to hashchange-events using the jQuery hashchange plugin.
- You'll need to load the hashchange plugin before calling this method.
- <br/>
- This method should be called after <code>ko.applyBindings(...)</code>.
- <br/>
- If an ID is supplied that ID will be set as initial <code>location.hash</code>.
-</p>
-
-<pre class="prettyprint">
-// your view model
-var viewModel = {
-};
-// extend viewModel with a $__page__ that points to pager.page that points to a new Page
-pager.extendWithPage(viewModel);
-// apply your bindings
-ko.applyBindings(viewModel);
-// run this method - listening to hashchange
-pager.startHashChange();
- </pre>
-
-
<h3><code class="code-large">startHistoryJs([id: String])</code></h3>
<p class="p">
@@ -80,23 +57,7 @@ <h3><code class="code-large">extendWithPage(viewModel : Object)</code></h3>
<code>ko.applyBindings(...)</code>
</p>
-<h3><code class="code-large">navigationFailed : Observable({page,route})</code></h3>
-
-<p class="p">
- A global observable that is triggered every time a navigation fails.
- The observable has 2 members: route and page.
-</p>
-
-<pre data-bind="prettyprint: {}" class="prettyprint linenums">
-ko.computed(function() {
- var page = pager.navigationFailed().page;
- var route = pager.navigationFailed().route;
- if (page && page.getId() == null) {
- viewModel.newChildren.push({childId: route[0]});
- page.showPage(route);
- }
-});
- </pre>
+<h3><code class="code-large">onNoMatch : $.Callbacks({page:pager.Page,route:String[]})</code></h3>
<h3><code class="code-large">onBindingError : $.Callbacks</code></h3>
@@ -131,7 +92,7 @@ <h3><code class="code-large">useHTML5history: Boolean</code></h3>
<p class="p">
Default to <code>false</code>. If set to <code>true</code> the custom binding <code>page-href</code>
- will use the custom binding <code>page-href5</code>, thus giving true URLs instead of
+ will use true URLs instead of
hash bangs. If History.js is used (by setting <code>pager.Href5.history = History</code> after loading
History.js) a fallback solution with hash bangs will be used for older browsers.
</p>
@@ -170,7 +131,7 @@ <h3><code class="code-large">Href5.history: Object</code></h3>
<p class="p">
Defaults to <code>window.history</code>. Can be set to <code>History</code> if
- History.js is loaded. This object will be used by <code>page-href</code> and <code>page-href5</code>
+ History.js is loaded. This object will be used by <code>page-href</code>
when <code>useHTML5history === true</code>.
</p>
@@ -10,9 +10,9 @@ <h1>HTML5 History API</h1>
<pre data-bind="prettyprint: {}" class="prettyprint linenums">
// use HTML5 history
-pager.<a data-bind="tooltip: {}" title="tell page-href to use the binding page-href5">useHTML5history</a> = true;
+pager.<a data-bind="tooltip: {}" title="tell page-href to use true URLs">useHTML5history</a> = true;
// use History instead of history
-pager.Href5.<a data-bind="tooltip: {}" title="tell page-href5 to use History (from History.js) instead of window.history">history</a> = History;
+pager.Href5.<a data-bind="tooltip: {}" title="tell page-href to use History (from History.js) instead of window.history">history</a> = History;
// these two lines are as normal
pager.extendWithPage(viewModel);
@@ -7,7 +7,7 @@ <h1>Setup</h1>
<a href="https://raw.github.com/finnsson/pagerjs/master/pager.js">pager.js</a>
or <a href="https://raw.github.com/finnsson/pagerjs/master/dist/pager.min.js">pager.min.js</a>.
Choose between a naïve history manager (<code>pager.start([id: String])</code>),
- a history manager based on jQuery hashchange (<code>pager.startHashChange([id: String])</code>),
+ a history manager based on jQuery hashchange (<code>pager.start([id: String])</code>),
a history manager based on History.js (<code>pager.startHistoryJs([id: String])</code>)
or write your own.
</p>
@@ -26,6 +26,8 @@ <h2>Naïve history manager</h2>
<h2>jQuery Hashchange as history manager</h2>
+ Is the same as the naïve, but you need to include the jQuery hashchange plugin first.
+
<pre data-bind="prettyprint: {}" class="prettyprint linenums">
// use #!/ instead of the default #
pager.Href.hash = '#!/';
@@ -34,13 +36,17 @@ <h2>jQuery Hashchange as history manager</h2>
// apply the view-model using KnockoutJS as normal
ko.applyBindings(viewModel);
// start pager.js
-pager.startHashChange();
+pager.start();
</pre>
<h2>History.js as history manager</h2>
<pre data-bind="prettyprint: {}" class="prettyprint linenums">
+// Set in the head element
+&lt;base href="http://some/url/"/&gt;
+
+
// use HTML5 history
pager.useHTML5history = true;
// use History instead of history

0 comments on commit 474ab86

Please sign in to comment.