question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Q: Inline onload supposed to work ?

See original GitHub issue

Greetings from Brazil!

First of all, my sincere congrats for this amazing fw.

I have a simple question.

Why doesn’t the inline onload work at the case below?

import choo from 'choo'
import html from 'choo/html'
import log from 'choo-log'
import onload from 'on-load'

export const testView = (state, emit) => {

	function onloadFn(el) {
		console.log('onLoad!', el);
	}

	return html`
		<div onload=${onloadFn}>
			<h1>test!</h1>
		</div>
	`
}

const app = choo()
app.use(log())
app.route('*', testView)
app.mount('#root')

but this does work ?

import choo from 'choo'
import html from 'choo/html'
import log from 'choo-log'
import onload from 'on-load'

export const testView = (state, emit) => {

	function onloadFn(el) {
		console.log('onLoad!', el);
	}

	const tree = html`
		<div>
			<h1>test!</h1>
		</div>
	`

	onload(tree, onloadFn)

	return tree
}

const app = choo()
app.use(log())
app.route('*', testView)
app.mount('#root')

What am I doing wrong?

Would love to understand it better.

Keep it up!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
yoshuawuytscommented, Sep 30, 2017

Heya, sorry that docs aren’t up to date - will be focusing (full time) on getting more out in the next few weeks; so stay tuned! 😄

On Fri, Sep 29, 2017 at 9:39 AM Maciej Sitko notifications@github.com wrote:

It is something different as it just does dom onload event, which is most of the times a correct interface of GlobalEventHandlers

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/choojs/choo/issues/570#issuecomment-333128796, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWleuJP9EWYJ4AROiuYVJ01UirMPhDqks5snPMFgaJpZM4Pok-c .

1reaction
graforlockcommented, Sep 29, 2017

EDIT:

Well actually it won’t really work on divs in particular so discard me.

Use shama/on-load then

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trigger onload, inline javascript event - Stack Overflow
When body JS object is completely formed or in other words when body's content is completely loaded then onLoad event is fired ....
Read more >
onload Event - W3Schools
The onload event can be used to check the visitor's browser type and browser version, and load the proper version of the web...
Read more >
Cannot use inline 'onload' because of CSP · Issue #312 - GitHub
When you have a CSP without unsafe-inline , you cannot use onload inline. This it will throw an error, and therefore not load...
Read more >
Event Handling - Vue.js
Inline handlers: Inline JavaScript to be executed when the event is triggered (similar to the native onclick attribute). Method handlers: A property name...
Read more >
The Video Embed element - HTML - MDN Web Docs - Mozilla
The HTML element embeds a media player which supports video playback into the document. You can use for audio content as well, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found