When using conditional actions, is using the ternary operator the only option?
Eg: a modal with a form is displayed to edit to a record. There are two buttons: one to save; the other to save and then close the modal. Both buttons submit the form and then reload the data. Only one of them closes the modal. After some experimenting I came up with this:
dmx-on:success="{{update_closedialog.value?data_detail1.mdl_update_record.hide():’’;sc_fairs_list.load({})}}"
I don’t need the ternary operator - if the test fails (if the variable has no value), I don’t need the second result, so I’ve used ‘’. This works, but it doesn’t seem ideal. It would be neater to use an ‘if’ statement, but I couldn’t get this to work. Can other methods be used in such cases - eg using if, else, or switch statements?
There are many cases where I might need to hand conditions like this and it would be helpful to know if there are different methods available.
Last updated: