For there record, INIT and SHOW seem to still be out of sync with
*! onsenui v2.0.0-beta.10-build.2713 - 2016-04-22 */
Posts made by claudioc
RE: Need clarification on Navigator events
@Fran-Diox Hi Fran
I am actually using
/*! onsenui v2.0.0-beta.10-build.2678 - 2016-04-21 */(and as you might now, the issue is a regression bug because it was working as it’s supposed to with a previous beta).
But OK, then, I will build/fetch a more recent nightly and I’ll consider this fixed.
I am listening to the Navigator events because to me it acts like a “frontend controller”: I reset/push on it and then listen to its init/show to manage the page (via a “view” object which takes the page element as its input – using the
But I might reconsider this approach if I can figure out another way to do it, and been able to bind the events on every single page as soon as possible (I have this problem where I have to replace the content of the texts for i18n and right now it works perfectly without any text “flashing”).
Thank for your work, man
P.S. there is a missing test for the “show” event of the navigator… I hope that that event is not going anywhere then
Need clarification on Navigator events
OnsenUI 2, latest beta
I am using a stack of pages and the “standard” navigator events (as per the documentation), are “pre/post push” and “pre/post pop”. I’ve been also using “show” and “init”, though (on the navigator itself).
I need to attach behaviours to the elements on the page (clicks, for example), plus I need to fill in some of the elements with data.
Now I am not sure where I should attach that logic: apparently, the “show” event is fired before the init (which seems weird to me).
Question is: using the navigator events, when is that I could be sure that the page has been inserted in the DOM and when should I need to use the “show” event, if I need it?
@OnsenUI I am using
ons-colto distribute input elements in a form. In the case where I need two inputs on the same row, those inputs need to be spaced. To accomplish that using only structural element (which act as my layout elements) I did this:
<ons-col class="addr-zip" width="33%"> <ons-input modifier="material" float placeholder="ZIP Code"></ons-input> </ons-col> <ons-col width="16px"></ons-col> <ons-col class="addr-city"> <ons-input modifier="material" float placeholder="City"></ons-input> </ons-col>
that is a placed an empty
ons-colelement between the two. I am almost happy with the solution (everything works perfectly thanks to the onsenui “layout engine” and no exception are added in the CSS), but I wonder if there is a better solution which doesn’t involve an additional element and/or hacking the CSS.
RE: I am missing a `bootstrap` method for non-angular apps
You’re right. I forgot that I had the
pageattribute on the navigator
This only solves part of the problem though, because once the
ons.readyis fired, my
ons-templates in the DOM are empty, like they have been “consumed” (and it’s OK, I guess ONS stores them in memory, out of the DOM). So it’s too late for me to replace the strings inside them.
I guess I will stick with changing the strings on each page’s
initevent handler. No big deal.
(I’ll update to the latest beta right now)
I am missing a `bootstrap` method for non-angular apps
I think my use case is not that exotic: I just need to preparse my
ons-templates to have some placeholders replaced on them (specifically, I am talking about i18n strings). I am not using Angular, so that the
bootstrapglobal function is not available.
I include onsenui.js as a normal file so that I don’t have a way to put it “in pause”, load my strings (via an ajax call), change the templates and then let it do its job as usual, using the now “translated” templates.
I also tried loading onsenui (beta 5) via
require()but it apparently doesn’t work. I get some weird “jsmutationobserver” error. I am using webpack and not browserify, so maybe that’s the problem.
Anyway, I understand that this not a simple problem to solve, since by default onsenui bootstrap itself automatically and changing this default is not possible of course.
Maybe, adding a class to the
bodyor an attribute to the
Thanks for listening
P.S.: my current solution is to compile those strings on-the-fly on the
initevent of the navigator (so, each time I am about to show a page). I still have problem bootstrapping, because of the asynchronous ajax call to fetch the language file but I can deal with it.
Using ons-template as reusable partials?
I am creating a “multistep” registration form with OnsenUI 2 using a page for each “step” and I find myself keep repeating the
ons-toolbarcomponent on each page (it always contains the same content for all the pages).
Is there a way to create an
ons-templateelement just for the toolbar and then reusing it over and over inside all the pages without the need to actually copy its content (you know, DRY).
Something like “partials”…