Rewrite: onenter
Closed this issue · 2 comments
kevindeyne commented
We will need a custom tag for a onenter event.
In Medusa 0.x this worked like m:click="increaseCounter(1, 'ABC')
The goal is to be able to reference a method on the controller side directly.
- Should be able to refer to a method without parameter
doAction()
- Should be able to add parameters to the method
doAction(1, 'ABC')
- Should be able to refer to other values (ie if I click, send the value of an input field as parameter); I have no requirement on how to refer to this, my suggestion would be
doAction(#mySearchField, 123)
- Should be able to refer to your own value
doAction(this.value, 123)
, again - not sure what the best way to write this would be
dirkdeyne commented
Add extra JS? rewrite-1.0.0-onenter
Given
<input id="search_enter" m:enter="search(:{#search_enter})" type="text" >
Result
<input id="search_enter" type="text" onkeypress="if(event.key === 'Enter') { _M.doAction(null, `search('${document.querySelector('#search_enter').value}')`) }">
dirkdeyne commented
See PR #310
A cleaner solution then rewrite-1.0.0-onenter
Calls JS-function doActionOnKeyUp
- Should be able to refer to a method without parameter
doAction()
- Should be able to add parameters to the method
doAction(1, 'ABC')
- Should be able to refer to other values (ie if I click, send the value of an input field as parameter); I have no requirement on how to refer to this, my suggestion would be
doAction(:{#mySearchField}, 123)
- Should be able to refer to your own value
doAction(:{this}, 123)
, again - not sure what the best way to write this would be