I am having trouble understanding the back button behavior in my alloy application in android. The scenario is this:
I am loading a widget in one of my windows to which I pass some parameters to use. I am retrieving these arguments in the standard way:
var args = arguments[0] || {};
On window close, I am setting the args to null. Now, this works fine as long as I close the window using my close button. args is set to null, and re-instantiated when I open the window again.
When I close the window with back button, args is set to null, but is never re-instantiated once I open the window again, and remains null. I have checked this with both heavyweight and light windows.
What all things does back button do? How can I enable re-instantiation of all the arguments again on opening the window?
Code: index.xml
<Alloy>
<Window id="myWin" class="container">
<View layout="vertical">
<Require type="widget" src="myWidget" id="myWidget" title='mainWindow' close='mainWindow' />
</View>
</Window>
</Alloy>
index.js:
// setting args to null on window close
$.myWin.addEventListener('close', function () {
$.myWidget.resetData();
});
Inside myWidget's controller, widget.js:
var args = arguments[0] || {};
// sets args to null
function resetData() {
args = null;
}
exports.resetData = resetData;
The above code does not re-initiate args once set to null (when we close window with back button). If however, I export args and set it to null in window controller, it shows there that args is null, but args has all the data once we re-open the window again even though it is not initiated again.
Code: index.js
$.myWin.addEventListener('close', function () {
$.myWidget.args = null;
});
Inside myWidget's controller, widget.js:
exports.args = args;
What exactly is going on here?
Aucun commentaire:
Enregistrer un commentaire