knockout checkbox event

460 views
Skip to first unread message

vivek...@gmail.com

unread,
Oct 29, 2013, 1:55:56 AM10/29/13
to knock...@googlegroups.com
present address <input data-bind="value: pratt"/><br>
<input type="checkbox" data-bind="event:{change: same}"/><br>
Permanent address <input data-bind="value: pmadd"/><br>
<script>
function AppViewModel() {
    this.pratt = ko.observable("");
    this.pmadd = ko.observable("");
    this.same = function(){
        $(abc ).toggle(); 
        var abc = this.pradd();
        this.pmadd(abc);
    }
}
ko.applyBindings(new AppViewModel());
</script>

I want to get value from first textbox to another on button click and on uncheck remove the value in textbox

Rachel Silver

unread,
Oct 29, 2013, 10:58:43 AM10/29/13
to knock...@googlegroups.com, vivek...@gmail.com
You can easily make a function that you bind to a button click to handle grabbing the text. As for the unchecking of the checkbox, I'd probably go ahead and make a manual subscription to the value rather than using the event binding.


vivek...@gmail.com

unread,
Oct 29, 2013, 10:09:23 PM10/29/13
to knock...@googlegroups.com, vivek...@gmail.com
THanks,but i want only checkbox,when it is checked copy,when unchecked clear the field.

vivek...@gmail.com

unread,
Oct 30, 2013, 2:01:48 AM10/30/13
to knock...@googlegroups.com, vivek...@gmail.com
What if second textbox has value and on uncheck the checkbox revert back to the original data.
Reply all
Reply to author
Forward
0 new messages