hyperapp icon indicating copy to clipboard operation
hyperapp copied to clipboard

Add onChange

Open maxadorable opened this issue 9 years ago • 2 comments

const { h, app } = hyperapp
/** @jsx h */

app({
  model: 200,
  actions: {
    change: model => model + 1,
    sub: model => model - 1,
  },
  view: (model, actions) => (
    <div className="well clearfix">
         <textarea className="form-control"
             onChange={actions.change}></textarea>
      <br/>
      <span>{model}</span>
      <button className="btn btn-primary pull-right"
        disabled={model === 0} 
        onClick={actions.sub} >
        Send</button>    
    </div>
  )
})

I noticed that if I type in the textbox, the change function does not get activated.

Will it be added?

maxadorable avatar Apr 12 '17 07:04 maxadorable

@AG-Systems I think you want onInput, not onChange.

Try this:

app({
  view: state =>
    <input
      onChange={console.log}
      onInput={console.log}
    />
})

jorgebucaran avatar Apr 12 '17 07:04 jorgebucaran

@jbucaran @AG-Systems beware that onInput doesn't work on select in IE/Edge. It's an open bug since years...

FlorianWendelborn avatar Apr 12 '17 12:04 FlorianWendelborn