Variables can be used with dynamic events but there seem to be some limitations - or it could be that I’m doing something wrong.
I have a page displaying records which can be searched in various ways: using a keyword search, several category menus or using an advanced search. This all works fine if I use links. However to avoid page refreshes, I’m using onclick events and query manager to set the URL parameters.
This works very well until you switch between search methods - eg using the advanced search, a series of URL parameters are created and will have to be cleared before using a category ‘link’ for example - so the link might start:
dmx-on:click="qm1.set('category','myCategory)
but will then be followed by a long series of ‘removes’
qm1.remove('field1');qm1.remove('field2');qm1.remove('field3');qm1.remove('field4');
etc.
The list of removes (in this case, over 10 of them) will need to be included in every onclick event, every category in a menu etc. - ie the same line will need repeating over and over again. It would obviously be better to put the list of ‘removes’ into a variable and declare it once.
This works as a partly dynamic onclick event:
dmx-on:click="qm1.remove(var_field.value)"
but not if I put the the whole string into variable. Eg if I create a variable:
var_remove: 'qm1.remove(\'subject\')'
Then this won’t work:
dmx-on:click=“var_remove.value”
I would like to be able to put any variable inbetween the quotes. Is there a particular reason why this isn’t possible or am I going about it in the wrong way? Is there any other way to do this in Wappler?
For the time being I’ll use PHP, eg:
dmx-on:click="<?php echo $removeparams ; ?>qm1.set(
etc.
where $removeparms is a list of URL params to be cleared before the next onclick event is fired.
I hope this makes sense. A related topic was raised a while ago - suggesting it would be very useful if we could have an action to clear multiple parameters.
Last updated: