nativescript-checkbox
nativescript-checkbox copied to clipboard
Tap event getting wrong value
Hello i need to add a event checkstate changed. I am trying add a tap event. But its getting first state of switch. I i tap checked switch getting checked prop True.
Can you provide all of your code involved and platform, device info?
On Thu, Mar 16, 2017, 9:43 AM Cagatay Oncul [email protected] wrote:
Hello i need to add a event checkstate changed. I am trying add a tap event. But its getting first state of switch. I i tap checked switch getting checked prop True.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bradmartin/nativescript-checkbox/issues/25, or mute the thread https://github.com/notifications/unsubscribe-auth/AFulhJ0sxfhdRE4vES1CEgHHSSWwCaOLks5rmUqVgaJpZM4MfZrZ .
<CheckBox:CheckBox row="1" col="2" tap="checkTap" colspan="2" text="Show" checked="{{ filter.show }}" />
exports.checkTap = function(args){
console.log(args.object.checked); // returns first state of checkbox
}
I am trying on Android. I need to get event check state changed.
I've not tested anything but try calling the toggle
method on the check box to switch its value. Then get the value.
If you want the change event use the following
<CheckBox:CheckBox row="1" col="2" checkedChange="checkTap" colspan="2" text="Show" checked="{{ filter.show }}" />
exports.checkTap = function(args){
console.log(args.value); // returns first state of checkbox
}
@triniwiz thank you. İ didnt see that property :)
@triniwiz its not worked.
#27
i added a pull request for this event handler
@cagatayoncul works fine for me in Angular
hi triniwiz , is it possible to change the color property of checkbox . like: our checkbox border color is grey when i click on it then checkbox color will be fill with different color. plz reply .
@himanshu331 android or iOS
In nativescript ..
Try to put the code inside the setTimeout function:
//xml <CheckBox:CheckBox id="item1" text="testName" tap="_checkTapped"/>
//script function _checkTapped() { console.log("tapped"); setTimeout(() => { let checkBox = topmost().getViewById('item1'); console.log('checked prop value = ' + checkBox.checked); }, 100); }