bootstrap-for-ember
bootstrap-for-ember copied to clipboard
some examples for dynamic links pls?
the showcase doesnt show an example for linking to routes with dynamic links.
lets say i got some pills as nav:
{{bs-pills contentBinding="nav" selectedBinding="selected" stacked=true style="max-width: 300px;"}}
and the linked property:
App.ApplicationController = Ember.Controller.extend({
init: function() {
this._super();
this.set('nav', Ember.A([
Ember.Object.create({title: 'Statistics', linkTo: 'content.stats', href: '#!/stats'}),
]));
//this.set('selected', this.get('nav').objectAt(0));
},
});
how do i link to a ContentRoute that uses a slug or a post_id for example?
the nav needs to end up to my ContentRoute that looks like this '/:slug'
App.ContentRoute = Ember.Route.extend({
model: function(params) {
return $.when($.ajax({
url: u + 'as' + params.slug
})).then(function(d) {
var model = {};
model.html = d;
return model;
});
}
});
App.Router.map(function() {
this.resource('content', { path: '/:slug' });
});
it doesnt seem to be possible..?
thanks
i basically have no clue how to use the 'pillAsLinkView'
Bootstrap.BsPill = Bootstrap.ItemView.extend(Bootstrap.NavItem, Bootstrap.ItemSelection, {
template: Ember.Handlebars.compile('{{#if view.content.linkTo}}\n {{#if view.parentView.dynamicLink}}\n {{#link-to view.content.linkTo model}}{{view.title}}{{/link-to}}\n {{else}}\n {{#linkTo view.content.linkTo}}{{view.title}}{{/linkTo}}\n {{/if}}\n{{else}}\n {{view view.pillAsLinkView}}\n{{/if}}'),
pillAsLinkView: Ember.View.extend({
tagName: 'a',
template: Ember.Handlebars.compile('{{view.parentView.title}}'),
attributeBindings: ['href'],
href: "#teste"
})
});
What exactly are you trying to achieve ? If you need pills that changes routes then you probably should take a look at: http://localhost:9000/#/show_components/tabs-with-routes
that's almost it, but how do you pass dynamic segments? (arguments)
such as
{{#link-to 'photo.edit' 1}}
or
{{#link-to 'photo.edit' model}}
is it possible or not?
i did some digging
if dynamicLink is set, it will use the current model. this should recognize the identifier set in the route then. but it still isnt working.
bs-nav.max
' {{#if view.parentView.dynamicLink}}\n ' +
' {{#link-to view.content.linkTo model}}{{view.title}}{{/link-to}}ee\n ' +
' {{else}}\n ' +
// view
{{bs-pills contentBinding="nav" selectedBinding="selected" stacked=true dynamicLink=true}}
// route
this.resource('content', { path: '/c/:slug' });
// array with models
this.set('nav', Ember.A([
Ember.Object.create({title: 'SomeLink', linkTo: 'content', slug: 'test1'}),
@ecoli1, have you found the solution? It's buggin' me whole morning ...
@alesvaupotic nah i gave up
Same here. Thx for replying.
@ecoli1, @alesvaupotic What did you guys end up using instead of this?
I really suggest you all to use the List component
I will also planning to release it as an ember addon today.
Thanks.
You could use this addon (with a demo here), it's meant to handle exactly these kinds of cases.
Hi asross, After searching a lot for dynamic link in ember, i was happy to see your add on. It works fine. but when the page loads, it displays, depreciation error as below
"DEPRECATION: You modified view.href twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 3.0 [deprecation id: ember-views.render-double-modify]".
It will be very helpfull, if you can give a work around for this.
Thanks.
Hi @kavithapazhanee , I will take a look at that and submit a fix soon. Thanks for reporting it!
@kavithapazhanee I tried to replicate the issue, but I'm having difficulty. Could you give more details / maybe make an issue in the repo?