datastar
datastar copied to clipboard
data-on-click.outside problem
click on 0 should be RowID: 0, then 1 - 1 click on document should be outside. somehow outside works for 2 clicks and stops.
templ Test() {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Document</title>
<script type="module" defer src="https://cdn.jsdelivr.net/npm/@sudodevnull/datastar"></script>
</head>
<body data-store="{ row_id: '' }">
<div>
RowID: <span data-text="$row_id"></span>
</div>
<hr/>
for i := range 10 {
<button data-on-click={ fmt.Sprintf("$row_id = '%d';", i) } data-on-click.outside="$row_id = 'outside';">Click me { strconv.Itoa(i) }</button>
}
<hr/>
</body>
</html>
}
you can't have to data-on-click's on the same element. it's a limitation of the data-* spec @blinkinglight
i think problem could be that https://github.com/delaneyj/datastar/blob/main/packages/library/src/lib/plugins/attributes.ts#L325 nothing resets called. with 2 different fields it still works for 1st 2 times and then never shows me .outside
https://alpinejs.dev/directives/on#stop https://alpinejs.dev/directives/on#outside
Hmm, got a PR in mind? I'll have to play with it a bit to figure out the right approach. Thanks for bringing to my attention. What are you think in regards to the stop part and how it effects this?