Aurelia page life-cycle - aurelia

I had a problem with Aurelia's binding system. I want so.e clarification on how view and viewmodels interact.
Lets say I have a div. This div has child divs that get generated by Aurelia's "repeat.for". I then have a function that does something to the parent div and its children. Where or when do I call this function. From experience, I cant call the function in the attached() hook because Aurelia's binding system is asynchronous so not all child divs may be ready by the time I call my function

Related

Iconic Vue PopoverController/ModalController with custom events

I am trying to use the PopoverController in Ionic 6 with Vue 3 (Composition API). Now, as I can not just add an #custom-event to my popover, I do not know, how to respond to custom events from my popover inside the parent component. Of course, you could pass callbacks as props, but that's pretty much an anti-pattern in vue.
Any ideas on how to pass custom events from the popover created by the popover controller to the parent?

Dynamically loaded html doesnt have access to viewModel

I will give a simple case scenario to illustrate my problem. I have a view and a viewModel. The viewModel has a method redirect(). After my view and its model are loaded I dynamically add a html button to the page and use click.delegate to link to method redirect() in viewModel. But clicking the button doesn't call the method. How to fix this.
If binding is not a possible workaround
You cannot add new bindings to the DOM through DOM manipulation because they will not be bound properly.
Instead you should either conditionally show it -
<button click.delegate="redirect()" if.bind="showRedirect">Redirect</button>

DurandalJS - Widget is not reinitialized on subsequent requests

This is an example of the problem: widget is not reinitialized on subsequent requests
I have a "pager" widget. The first time I navigate to a page where it is used, ctor is executed and the pager is initialized (page 1).
Now let say I navigate to page 6.
The problem is when I navigate to another page and then back to the page where the pager is, the pager (widget) is still rendered with page 6 selected and ctor is not executed. The widget controller is not a singleton.
Is there something I don't get?
Since the page is not re-rendered (so the widget), none of the widget's life cycle callbacks will be called. What you can do though it to communicate with widget from parent page's activate method by
Raise an event from root page's activate method which widget
listens
Update data in some observable which widget subscribes to
Or, dirty way - don't do it, just re render the widget by
wrapping widget with with/if binding which would change for each
activate method call. This may be helpful if you cannt change the
widget code, which is very unlikely.

Sencha touch: Are events not propagated down?

Noob question.
I have an activate handler in a child List, but it doesn't fire. The activate event on the parent Panel does fire. I tried several other events, and none of them propagate down down the hierarchy. Is this really the intended behavior? If so, how can I ensure that nested widgets initialize properly?
Thanks.
I don't know if its intended behavior but you could add activate listeners on all members of the hierarchy and iterate through the child elements to initialize.
The intended events surely fire for each of the components. For your case, are you adding the activate event in controller? Check if your reference is proper or put that listener in the list component itself and test.

Difficulty in deciding where to put the code in yii view helper

I'm new to yii development.
In my system I'm trying to create a submenu system. The submenu will be shown based on the
controller. The submenu will be separate views, that I'll load in main layout.
I want to separate the logic of loading the submenu view from the main layout. But, I'm not sure where to write it.
Does Yii has view helpers like in RoR. Or, should I write it as a component?
Please give suggestions.
Thanks.
I'd just create a component for this, and instantiate that with the relevant menu options from the controllers. If present in all controllers, implement support in a BaseController and just set up an array of items in the child controllers.
Your default generated Yii application has a parent Controller in protected/components/Controller.php. If you need to access additional parameters in layout, add public properties to Controller, set them in your child controller, and use them in your view/layout files.
In your case, add a function to this parent Controller that returns a rendered submenu (with a renderPartial call for example) and call this function from your layout.