Skip to content
Discussion options

You must be logged in to vote

not possible, the square syntax is a standard javascript thing to allow the usege of a variable value as a key via interpolation, the content should resolve to a single value. It's not a custom Alpine feature.

In your case,

'x-on:dragstart.self'() {
     this.dragged = this.$el;
}

would work as well but using square brackets you can have stuff like

let foo = 'x-on:dragstart.self'
...
[foo]() {
     this.dragged = this.$el;
}

Or
would work as well but using square brackets you can have stuff like

let foo = 'dragstart.self'
...
['x-on:' + foo]() {
     this.dragged = this.$el;
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Yinci
Comment options

Answer selected by Yinci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants