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:
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 ?
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
Post a Comment