When I call a method on init from within methods object:
on: {
init: function() {
this.methods.myMethod();
in myMethod I can not access var app (for example to call another method or access the app.data object). When I console.log(this), it only contains app.methods object.
Is this intended?
In my experience even the following snippet from the documentation does not work, when I call the method on init, because app is not accessible. What I am missing and how is this supposed to work?
var app = new Framework7({
methods: {
alert: function() {
app.dialog.alert('Hello World');
}
},
on: {
init: function () {
this.methods.alert();
}
}
});
Hi, do you use components?
you can listen to a page init event, and then run the method of that page. A little more of code will help to get the idea of what you are trying to do.
Looks like an issue, already pushed fix for this https://github.com/framework7io/framework7/commit/47e4077d0637a0d422215c69bd64c08f784e565b
So yeah, this
inside of method should point to app
instance
1 Like
you can listen to a page init event, and then run the method of that page.
I wonder whats the idea here ? and whats the reason for using it
call a method in a component from another component ?
or call a method in a component from app.vue ?
Do we have to use the Beta version of 3? Because we tried and it does not work, also in v2.
Yes, it is in beta 3 at the moment