Hey Patrick,
Yeah, I was going there next.
I need to remove the Servoy anchor (for method trigger) and just use a WebClient plug-in callback to trigger the script I need.
I was hoping to just have a "normal" Servoy anchor link and then flip the image with jQuery. I've tried some different techniques:
- Code: Select all
<a href="javascript:myMethod();><img src="media:///image.png"></a>
This was no good - because Servoy re-writes the asset URL (which is no problem to decode). So then I tried using the raw asset url rather than the "media" shortcut. I could change the src - and the page would recognize it (via the console), but the mark up did not update.
Then, I tried this:
- Code: Select all
<a href="javascript:myMethod();><div class="red-button"></div></a>
The div class has a CSS background URI. Renders perfectly. So, I thought that I would just trigger the Servoy method and then flip the class of the div with jQuery.
(The UUID is the element ID, and I used the Servoy method to formulate the "sOldClass" and "sClass". The output of the variables is a class name: e.g. "red-button"):
- Code: Select all
sScript = "var $oObj = $('#" + sUUID + "'); \
$oObj.removeClass( '" + sOldClass + "' ).addClass( '" + sClass + "' ); \
$oObj.attr('args', '" + sNewArgs + "'); \
console.log(\"removed: '" + sOldClass + "', added: '" + sClass + "\");"
Again, the element would SAY that the class changed (by using the console to query the object), and the "args" attribute would update, but the image still would not change.
Then, I remembered what David Workman suggested - that I need to set a timeout to give more time - so I tried this:
- Code: Select all
sScript = "setTimeout(function() { \
var $oObj = $(\"'#" + sUUID + "'); \
$oObj.removeClass( '" + sOldClass + "' ).addClass( '" + sClass + "' ); \
$oObj.attr('args', '" + sNewArgs + "'); \
console.log('removed: '" + sOldClass + "', added: '" + sClass + "');\
},500);"
Still, no workie.
So, now, when I do the onClick method to trigger a callback - how do I get the image to change? This is a HTML list table that I created (not a built-in table view or list). I appreciate your help!