-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to do page jump when clicking a button inside a partial page? #14
Comments
Yes, I suppose that the Now, your In any event, if it's happening occasionally, then it sounds like a race condition. There must be two async things happening here, which normally happen in the desired order, but sometimes not. If I recall correctly, Of course, elm-route-hash isn't aware of your explicit use of All that being said, the general philosophy behind elm-route-hash is that ideally you shouldn't go through the hash in order to change your model -- you should just change your model in the ordinary way, and let the hash follow along. (That is, the url handling should sit alongside your normal state transformations, rather than being an essential part of them). So, ideally the best way to attack your problem would be by figuring out how to deal with this:
Now this, it seems to me, is an example of the general question of "How does a sub-component trigger a change in a parent's model?" And that, in turn, is a common question of general interest. In principle, there are only two possible answers:
Which, generally speaking, means modifying the standard signature of the child's
I did a little googling around children updating parent's state in Elm, and got this (amongst other things), which suggests one plausible approach: https://www.reddit.com/r/elm/comments/3plxaw/child_component_changing_state_on_parent/ Of course, I may have misunderstood your needs, but I think figuring out how to get children to update their parent's state might be helpful in your situation. |
In the example, there are event handlers in the TOC which changes "currentPage" in the model of the root page. This leads to a page jump.
However, inside a partial page, it seems not possible to update the model of the root page. Then how to do a page jump in a partial page.
I have tried 2 ways:
Use
<a>
tag and specify thehref
attribute.This really works well, but the limitation is that I have to use
<a>
tags. Sometimes page jump is required on other user events instead of link clicks.Make an Action in event handlers, and return
Effects
usingHistory.setHash
This works, but I found a strange problem that occasionally the page jump will finally return to the current page. (There is a flash)
I'm not quite sure why this happens. But I guess
location2action
ordelta2update
has been triggered multiple times in this scenario. Since theEffects
need anAction
type stand-by and I have to set it toNoOp
and do nothing with it. But will thisNoOp
action trigger a newdelta2update
?I'm confused with this behavior, and want to ask what is the best way to make page jump in a partial page.
The text was updated successfully, but these errors were encountered: