Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batman.js input value

I want to pass the value of an input field from the view to the controller. What's the best way to achieve this without binding the input field to a property of the model? Example:

view:

<form data-event-submit="searchHero">
    <input type="text" placeholder="Name..." data-bind="myquery"/>
</form>

controller:

searchHero: ->
    console.log myquery
like image 651
shoen Avatar asked May 21 '26 02:05

shoen


1 Answers

Actually, this code binds the input's contents to the myquery prop of the controller, so you can access it via standard batman's get:

searchHero: ->
  console.log @get 'myquery'
like image 160
nl_0 Avatar answered May 23 '26 14:05

nl_0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!