These are chat archives for mithriljs/mithril.js

7th
Oct 2015
Dominik Dumaine
@Bondifrench
Oct 07 2015 04:54
@tobscure
https://developer.mozilla.org/en-US/docs/Web/Events/change
oninput fires at each single character change in the field
onchange fires when the field is blurred etc.
Toby Zerner
@tobscure
Oct 07 2015 05:08
@Bondifrench I'm aware of that. Turns out it was a much more complicated issue :P flarum/core@538a3e5
Dominik Dumaine
@Bondifrench
Oct 07 2015 06:55
Thanks @tobscure Maybe that would be worth a mention in Mithril's wiki in Recipes and Snippets
Stephan Hoyer
@StephanHoyer
Oct 07 2015 07:04
@tobscure you allow vdom-els in translations… daring idea
Toby Zerner
@tobscure
Oct 07 2015 07:06
@StephanHoyer kinda! The translations themselves are plain strings with {placeholders} in them. Then we sub in vdom replacements. See https://github.com/flarum/core/blob/master/js/lib/Translator.js#L69
greeting: "Hello, {name}!"
app.trans('greeting', {name: m('strong', 'Toby')});
but you can’t use vdom-els as replacements there
but our plural support is much better :P
Rodrigo Álvarez
@Papipo
Oct 07 2015 08:07
I have been struggling by some sneaky bug, that happens to be a Promise.all that never returns
Rodrigo Álvarez
@Papipo
Oct 07 2015 08:13
woah
I was passing an undefined error handler to then()
everything hanged, and got no errors
how come
Stephan Hoyer
@StephanHoyer
Oct 07 2015 08:20
promises suck on errors
Rodrigo Álvarez
@Papipo
Oct 07 2015 08:23
it might be better to use then + catch
although I'm not sure that's exactly the same
Rodrigo Álvarez
@Papipo
Oct 07 2015 09:27
Do you use m.deferred or Promise? why?
Stephan Hoyer
@StephanHoyer
Oct 07 2015 11:18
m.deferred/native-promise in frontend
In fact I don’t really care, since they are basically the same since I don’t use any fancy stuff. But my error-handling is mostly not existing :)
Rodrigo Álvarez
@Papipo
Oct 07 2015 11:34
who cares :D
Leo Horie
@lhorie
Oct 07 2015 15:06
wow, lichess.org is the second largest chess site in the world. I had no idea.
Gilbert
@gilbert
Oct 07 2015 16:30
> syntax proposal is here: lhorie/mithril.js#630
it makes sense the moment you need it :)
@lhorie wow that's incredible
Justin Robinson
@xemoka
Oct 07 2015 17:40
Hey folks, I'm trying to interact with a 3rd party library and am wondering if there's a way to render out a virtual element without a target node, i.e. a way to get m.render to return the output html directly... or is there a better way to do this? [the third party library (leaflet) uses a function to attach content to a popup... ]
Gilbert
@gilbert
Oct 07 2015 17:43
Justin Robinson
@xemoka
Oct 07 2015 17:46
@mindeavor that sure does look like what I'm after...
@mindeavor thanks
Gilbert
@gilbert
Oct 07 2015 17:47
no problem
Justin Robinson
@xemoka
Oct 07 2015 17:47
yep, that's exactly what I want :smile:
sector119
@sector119
Oct 07 2015 19:25
@ArthurClemens I still have a struggle with tabs )) May be you'll be able to look at this snippet... https://dpaste.de/XanE
It switch pages, but tabs don't switch (animate).. It look like that when I switch to 2nd or third tab it switch to this tab, but then switch back to 1st...
And when I uncomment 'config' option, it removes max-width style property and break design... ))
@ArthurClemens I use last version of polythene, and polythene-theme from github
Arthur Clemens
@ArthurClemens
Oct 07 2015 19:31
I believe that the general solution should be to defer the route change until the animation is done
sector119
@sector119
Oct 07 2015 19:32
hm.. how to do that?
Rodrigo Álvarez
@Papipo
Oct 07 2015 19:33
Use the config attribute to animate, and change the route on animation end
But the component does not accept a callback to let you know when the animation is done. Currently slide duration is hardcoded to 250ms.
Arthur Clemens
@ArthurClemens
Oct 07 2015 19:39
I don’t understand the problem with the link configs
commented out == config = null, so does not use m.route
sector119
@sector119
Oct 07 2015 19:42
@ArthurClemens when I set url's config to m.route max-width style disappeared ))
@ArthurClemens so I just have to make a timeout > 250ms and then change route?
Arthur Clemens
@ArthurClemens
Oct 07 2015 19:43
yes
sector119
@sector119
Oct 07 2015 20:18

It does't work as expected
I add config: changePage to all url's:

let changePage = (element, isInitialized, context) => {
    if (!isInitialized) {
        element.onclick = (e) => {
            e.preventDefault();
            setTimeout(() => {
                m.route(element.getAttribute('href'));
            }, 1000);
        };
    }
};

Here you can see how it look like with config set: http://prntscr.com/8ov6n0
And without: http://prntscr.com/8ov7jn

When I click on tab, page content is switched, but tab doesn't

There are no styles on div.button and div.tabIndicator
Arthur Clemens
@ArthurClemens
Oct 07 2015 20:28
@sector119 Can you provide me your latest code?
sector119
@sector119
Oct 07 2015 20:33
@ArthurClemens https://dpaste.de/LJRk
Arthur Clemens
@ArthurClemens
Oct 07 2015 20:59
@sector119 Definitely a bug. The button config in tabs.js gets overwritten by the url config.
sector119
@sector119
Oct 07 2015 21:05
@ArthurClemens :)
it's ok )
sector119
@sector119
Oct 07 2015 21:11
i'd be waiting for fix )
Arthur Clemens
@ArthurClemens
Oct 07 2015 23:53
@sector119 I’ve fixed the bug, but the solution that you need is different.
If you checkout the latest examples, there is a new demo for “Tabs with routing”.
You can remove the function changePage and instead use:
app.controller = () => {
    m.redraw.strategy('diff');
};