I need to activate a select value in a website using Knockout.js using a browser extension.
I am using jQuery but I am a bit lost with the trigger ko methods.
This is the select that I want to change the value:
<select name="subDuration" class="select number_weeks" id="sub_duration"
data-bind="
options: options.durationOptions,
optionsText: 'val',
optionsValue: 'key',
optionsCaption: 'Select subscription duration',
value:options.duration,
event:{
change: options.updateDuration,
blur: options.validateDuration
},
attr:{
'aria-invalid': options.hasDurationError,
'aria-describedby': options.hasDurationError() ? 'sub_duration_error' : false
}
"
data-ctp-cont="Direct Debit Payments">
</select>
$("#sub_duration").focus().trigger("change", options).val(2).blur()
When I use the cde line above it puts the value as 2 but the site validation runs on blur and does not recognise it as valid. If I select something else or then 2 again it does. It feels like the jQuery change is not triggered in the site ko js validations.
Any idea of what I am missing here? Sadly I've never worked with knockout.js...
Any help is appreciated. Thank you!