Comments (6)
I'd find this very useful too.
We have the situation, where we allow links to open in a lightbox, but still change the URL. We do that with a special target tag. The easiest for our case would certainly be to have access to the dom element.
However that should probably not be the responsibility of page.js. Still I would like to be able to access the contents of that target attribute in my middlewares. One solution I can think of is to be able to manipulate the context
when calling #page()
inside my own click handler.
I was going to suggest to implement that. But it turns out, that something similar exists. You can prevent #start()
from calling #replace()
and then call #replace()
yourself and pass a state object like so:
page.start( { dispatch: false } );
page.replace( location.pathname + location.search, { target: "#selector" }, true, true );
Thats for starting, after that you can just use #show()
.
// inside your click handler
page.show( $this.attr( "href" ), { target: $this.attr( "data-target" ) } );
Just ignore that I assume jQuery ;) the idea stays the same.
from page.js.
The reference wouldn't be bad, but I am of the opinion that page shouldn't do any delegation at all, and that should be a separate component.
from page.js.
it seemed relatively non-leaky at the time but we're investigating better patterns for client-side routing, there's definitely a few gotchas/annoyances with page.js ATM
from page.js.
Although having links that automatically trigger pushState and a page() handler IS indeed very useful and I'd say covers a large percentage of use cases, so the functionality somehow needs to stay, maybe slightly different impl
from page.js.
it's stil pretty easy to do the inverse and .preventDefault() to disable page.js for links, the 80% use-case would be to dispatch so that still kinda works
from page.js.
we could always have some data-page
sort of thing to opt-in/out depending on what the default is. I'm using target="_self"
as a hack right now to bypass page haha
from page.js.
Related Issues (20)
- 'prevContext' on hash change not set properly
- bug for omitting query and hash from pathname
- Page reload on redirect page("./pageToRedirect") HOT 1
- Doesn't work with Github Pages? HOT 1
- page.len does not decrease after click browser's back button
- Relative link when current location has #hash triggers a reload while it doesn't with no #hash or empty # HOT 3
- can't access ctx.page.preContext, ctx === ctx.page.preContext returns true
- very simple page, but got 404 HOT 1
- page('/about', about); HOT 1
- What NPM Package should I use? "page" or "page.js" HOT 1
- Page base not used for history state (breaks reloading in electron) HOT 2
- Handling onpage hash links HOT 5
- It would be nice to have a minified version available
- Change route url without refreshing HOT 1
- Whether pathname includes base depends on whether there is an anchor (#foo)
- doc link 404
- Browser back/Forward button with saved warning message HOT 2
- history.state is cleared on initial page load
- is this project still active? HOT 8
- Worth forking? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from page.js.