Note that there are some explanatory texts on larger screens.

plurals
  1. POBackbone and jquerymobile navigation issues - hash in URLs
    primarykey
    data
    text
    <p>I am using backbone.js and WebMatrix. I have problems with hash(#) in url though. To be more precise, I have on my router file this code: </p> <pre><code>routes: { "" : 'myBooks', "books/:id" : 'bookDetails' } </code></pre> <p>and then i initialize the router</p> <pre><code>var initialization = function () { Backbone.history.start(); }; </code></pre> <p>So when I click this URL: "localhost:9548/#books/1" on my browser, the following message appears on my console (firebug) "NetworkError: 404 Not Found - //localhost:9548/books/1". I have found already posts trying to solve a similar problem but I am not at all familiar with IIS Express (server configuration in general). So some posts for example also refer to web.config of my web application but I do not have any.</p> <p>So for instance if I would create a web.config file with the following code </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;system.webServer&gt; &lt;rewrite&gt; &lt;rewriteMaps&gt; &lt;rewriteMap name="StaticRewrites"&gt; &lt;add key="index.html#books/*" value="index.html" /&gt; &lt;/rewriteMap&gt; &lt;/rewriteMaps&gt; &lt;/rewrite&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre> <p>would solve my problem? </p> <p>I apologize that I did not mention the fact that for the ui (and only) of my web app, I am using jquerymobile. Consequently, I have disabled the ajax navigation of jquerymobile: </p> <pre><code>$.mobile.ajaxEnabled = false; $.mobile.linkBindingEnabled = false; $.mobile.hashListeningEnabled = false; $.mobile.pushStateEnabled = false; $.mobile.changePage.defaults.changeHash = false; </code></pre> <p>Besides the change of a page is handled by this code: </p> <pre><code>var utility = {}; utility.changePage = function( viewID, effect, direction, updateHash ) { viewID.attr('data-role', 'page'); $.mobile.changePage( viewID,{changeHash: updateHash}); }; </code></pre> <p>Finally the function which handles my route is the following: </p> <pre><code>bookDetail: function (id) { var myBook = myCollection.get(id); var bookDetails = new BookDetails({ model: myBook }); $('body').append($(bookDetails.render().el)); $.mobile.changePage(bookDetails.$el, {changeHash: false }); } </code></pre> <p><strong>Important:</strong> There is a chance that the problem is occurred because of the last version of the jquerymobile (1.3.0). Precisely, disabling hashListeningEnabled does not work properly as I have read. Another feature is that I encounter this problem with Mozilla and Chrome but not with Internet explorer (using the last version of them). </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload