recurring_select icon indicating copy to clipboard operation
recurring_select copied to clipboard

How to set value via JS?

Open shir opened this issue 10 years ago • 1 comments
trafficstars

How I can set value via JS. I need to copy value from one field to another. There is almost none any documentation about JS part and it's not clear from source code.

I've tried to use:

# value = "{"interval":4,"until":null,"count":null,"validations":null,"rule_type":"IceCube::DailyRule","week_start":0}"
$(input).recurring_select("save", value)

but didn't have any success.

shir avatar Mar 10 '15 09:03 shir

Just in case if someone need to do same here is example:

var $opt = $form.find("select[name='recurrence_rules1']>option[value='" + p.value + "']"); // I have only value but function requires option to name to set with value
$form.find("select[name='recurrence_rules2']").recurring_select("save", {str: $opt.text(), hash: $.parseJSON(p.value)});

I think it should be in documentation or there should be added some method to make it easily, so I may do something like this:

$form.find("select[name='recurrence_rules2']").recurring_select("set", p.value);

shir avatar Mar 11 '15 09:03 shir