ember.js - Ember: how is the title of a post or article included in the browser URL? -


the standard url used in ember when showing route follows:

http://domainandsite/index.html/#/publications/145 

(thus showing publication id 145).

i saw in live ember sites 2 alternative representations:

  1. http://www.bustle.com/articles/3358-marc-jacobs-set-to-open-first-beauty-store-in-new-york

    thus, article title added id , forms new url. how done ?

  2. http://discuss.emberjs.com/t/what-is-the-future-for-the-emberjs-addons-organization/2168

    same question, how done.

i not have impression model contains concatenated id or ... looks fragment identifier used, how combine ember routes ?

you have override hooks model , serialize in route. following example how code publications like:

app.publicationroute = ember.route.extend({     serialize : function(context){         var rawstring = context.get("id") + " " + context.get("title");         return rawstring.replace(/ /g,"-"); // replace spaces wish or encode uri     },     model : function(params){         var partsofuri = params.slugname.split("-"); // split part of uri         var id = partsofuri.shift();          return app.publication.findbyid(id);     } }); 

also have @ api documentation model hook , serialize hook.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -