bind.js icon indicating copy to clipboard operation
bind.js copied to clipboard

Support for programmatically modified values?

Open twanlass opened this issue 10 years ago • 7 comments

For example, why doesn't this work? https://jsfiddle.net/k25zfbm7/

twanlass avatar Sep 28 '15 03:09 twanlass

Not sure I follow - the subject suggests there's a problem with input[type=hidden], but there isn't one...

remy avatar Sep 28 '15 10:09 remy

@remy my apologies - fixed the title, forgot to save.

Re: the jsfiddle above - wondering what I'm doing wrong or if this functionality is not implemented. I've got a few places where the input values are modified via jQuery et el but not seeing the binding update (no callback fired when changed etc).

Cheers!

-t

twanlass avatar Sep 28 '15 15:09 twanlass

I see a use case for that, when bind.js is used in a larger application, but you could still set the value programmatically in your example:

Instead of $('.name').val('tyler'); you use names.name = 'tyler'; instead.

AVGP avatar Oct 02 '15 06:10 AVGP

Oh, I think I follow now. Are you expecting the bound object to update when you change the input using jQuery?

If that's the case, I'm pretty sure you want to trigger a change event on the input element, since that's how bind.js is picking up the change.

$('input.name').val('tyler').trigger('change');

remy avatar Oct 02 '15 07:10 remy

@twanlass did that work?

remy avatar Oct 03 '15 15:10 remy

@remy - calling trigger('change') doesn't appear to, no.

twanlass avatar Oct 03 '15 18:10 twanlass

trigger('change') doesn't do the trick, any ideas?

adelriosantiago avatar Sep 22 '17 05:09 adelriosantiago