GithubHelp home page GithubHelp logo

Comments (4)

yysun avatar yysun commented on June 15, 2024

from apprun.

jkleiser avatar jkleiser commented on June 15, 2024

Doing onclick={e => location.hash = 'gameAsX'} does not seem like a possibility for me, as I also have to include some data. Today I do $onclick={["#gameAsX", game]}, but that does not change the URL.

from apprun.

yysun avatar yysun commented on June 15, 2024

You can send event parameters in the hash separated by / :

location.hash = ‘gameAsX/data1/data2’

or use history.pushState:

history.pushState(null, null, '#gameAsX/' + data);

See https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API

from apprun.

jkleiser avatar jkleiser commented on June 15, 2024

It seems I have found a working solution. I discovered that in my main.tsz, all calls to start() or mount() had a second route argument, like here:

new About().mount(element, {route: '#About'});

I had not seen this second argument in any of my previous SPA projects. I therefore removed it from my main component (the "G"). Then in a local "gameAsX" event handler in my "R" component, I did the global app.run("#gameAsX", game) which would be handled by my "G" component, followed by location.hash = "#G" to fix the URL.
If this is the optimal solution, I don't know, but at the moment it works.

from apprun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.