bootstrap-for-ember icon indicating copy to clipboard operation
bootstrap-for-ember copied to clipboard

some examples for dynamic links pls?

Open ghost opened this issue 10 years ago • 14 comments

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

ghost avatar Mar 15 '14 11:03 ghost

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"
    })
  });

ghost avatar Mar 15 '14 20:03 ghost

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

asaf avatar Mar 19 '14 05:03 asaf

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}}

ghost avatar Mar 19 '14 17:03 ghost

is it possible or not?

ghost avatar Apr 06 '14 18:04 ghost

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'}),


ghost avatar Apr 06 '14 19:04 ghost

@ecoli1, have you found the solution? It's buggin' me whole morning ...

alesvaupotic avatar Jun 12 '14 12:06 alesvaupotic

@alesvaupotic nah i gave up

ghost avatar Jul 21 '14 10:07 ghost

Same here. Thx for replying.

alesvaupotic avatar Jul 21 '14 10:07 alesvaupotic

@ecoli1, @alesvaupotic What did you guys end up using instead of this?

hglattergotz avatar Jan 12 '15 12:01 hglattergotz

I really suggest you all to use the List component

I will also planning to release it as an ember addon today.

Thanks.

asaf avatar Jan 13 '15 13:01 asaf

You could use this addon (with a demo here), it's meant to handle exactly these kinds of cases.

asross avatar Jul 20 '15 17:07 asross

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.

kavithapazhanee avatar Jan 14 '16 15:01 kavithapazhanee

Hi @kavithapazhanee , I will take a look at that and submit a fix soon. Thanks for reporting it!

asross avatar Jan 14 '16 19:01 asross

@kavithapazhanee I tried to replicate the issue, but I'm having difficulty. Could you give more details / maybe make an issue in the repo?

asross avatar Feb 05 '16 21:02 asross