framework icon indicating copy to clipboard operation
framework copied to clipboard

Using element selector in view model used in composition doesn't work

Open tomshane opened this issue 7 years ago • 3 comments

I'm submitting a bug report

  • Library Version: 1.1.2

Please tell us about your environment:

  • Operating System: Windows 10 Pro

  • Node Version: 6.10.0

  • NPM Version: 3.10.10

  • Aurelia CLI OR JSPM OR Webpack AND Version webpack 2.2.1

  • Browser: all

  • Language: TypeScript 2.3

Current behavior: Using selector in a viewmodel to get an element marked with ref="" doesn't work when the view/viewmodel is used in a composition.

View: <ul ref="history"> ViewModel: attached() { console.log(this.hisory); } returns undefined.

Expected/desired behavior: Referenced element should be available in the viewmodel.

tomshane avatar May 11 '17 06:05 tomshane

Can you provide a full sample? I'm not quite following the specifics...

EisenbergEffect avatar May 14 '17 06:05 EisenbergEffect

You misspelled history in your viewmodel (it is spelled hisory in the code you posted). If you've copied the code from your project, that might be the cause.

AshleyGrant avatar May 15 '17 00:05 AshleyGrant

It is not actual code.

Because at the moment I don't have a sample I could provide, I try to describe the problem slightly better.

I create a view and a view-model and in the view I use ref="whatever" on an element to be able to reference it from my view-model via this.whatever. If I use this view/view-model pair in composition <compose view-model="${item.content}" model.bind="item.section"></compose> inside another component, the reference is not created and this.whatever returns undefined.

tomshane avatar May 15 '17 05:05 tomshane