Comments (2)
unpoly.js
must never be included more than once. Here is what happens:
- The initial page is loaded. The browser sees the script for
unpoly.js
<body>
, loaded and run. - You click on the link. Unpoly loads the link destination.
- Because Unpoly cannot find a main element it swaps the
<body>
element. - The browser sees the script for
unpoly.js
in the new<body>
and runs it a second time. This throws an error.
Here are three ways to fix this (you only need one):
- Move your scripts into the
<head>
and use the<script defer>
attribute. This is superior to putting your script at the end of the body. - Wrap your content into a
<main>
or[up-main]
element so Unpoly does not need to swap the<body>
. - Configure
up.fragment.config.runScripts = false
from unpoly.
New finding
It seems the issue is because the unpoly script is put in the <body>
instead of <head>
I think maybe it's worth mentioning that the script must be put in the <head>
instead of the end of <body>
from unpoly.
Related Issues (20)
- snipcart with unpoly HOT 2
- Incorrect docs: Event target for 'up:form:submit' is not always the form HOT 5
- Is up-disable broken? HOT 2
- `up.animate` does not respect `duration: 0`
- Question: Async code in 'up:form:submit' possible race condition? HOT 2
- no transition with tailwindcss
- Web Component form field dropped by up-submit HOT 2
- Can unpoly exchange HTML fragments through WebSockets?
- Look at explicit port for cross-origin detection HOT 1
- Successfully submitting a form within a layer with the param up-layer='root' closes the layer with up:layer:dismiss and not up:layer:accept event HOT 1
- Watching fields requires multiple-values checkboxes to have a `[]` name suffix HOT 9
- Handle links with anchors that start with a number HOT 1
- Handle links with anchors that start with a number HOT 1
- Browser does not loose it's zoom state between page navigations on smartphones HOT 2
- URLs with redundant slashes cause Unpoly to trigger a `DOMException` HOT 1
- HTML lang attribute is not updated on link follow HOT 1
- 3.8 up-defer shouldn't requires click HOT 7
- Unable to submit `up-accept` or `up-dismiss` links with the keyboard within popups
- Modal forms retain old values after editing 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 unpoly.