-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Description
I have a check box which I have registered a JS callback for in order to hide / show some fields, as you can see there are a couple console logs in there to help me debug.
The problem with this is that for each change in the checkbox so unchecking it or checking it this code fires twice. with some odd results. See below the code for what I am getting as a console output.
function overrideTermChecked (changed, collection, shortcode) {
function attributeByName (name) {
return _.find(
collection,
function (viewModel) {
return name === viewModel.model.get('attr');
}
);
}
var updatedVal = changed.value,
override_term = attributeByName('term'),
override_msg = attributeByName('content');
console.log(typeof updatedVal);
console.log(updatedVal);
if (updatedVal) {
console.log('Should Show');
override_term.$el.show();
override_msg.$el.show();
} else {
console.log('Should Hide');
override_term.$el.hide();
override_msg.$el.hide();
}
}
wp.shortcake.hooks.addAction('glossary_tooltip.override', overrideTermChecked);
So I am not able to make the 2 text fields for term / content show they remain hidden all the time. Is this an issue with my implementation?
Metadata
Metadata
Assignees
Labels
No labels
