
Originally Posted by
artinteg
Can you share some code snippet?
OK.
Original code combines MWL and DOM calls:
Code:
<img id="get_bus" src="img/go_button.png" onclick="mwl.switchClass('#slider', 'show_toc', 'show_scratchpad');
mwl.insertHTML('#subtitle', 'Next bus at stop ID ' + document.getElementById('stop_id').value);
getAction1(document.getElementById('stop_id').value);" alt="" />
Modified code: moved the DOM logic from the index.html page to the getAction1() JS function. Note that I replaced the original text with "Loading...." since there will be a wait until the server processes the JS.
Code:
<img id="get_bus" src="img/go_button.png" onclick="mwl.insertHTML('#subtitle', 'Loading . . .' );
mwl.switchClass('#slider', 'show_toc', 'show_scratchpad');
getAction1();" alt="" />
...and the function itself
Code:
function getAction1()
{
var sid = document.getElementById('stop_id').value;
mwl.insertHTML('#subtitle', 'Next bus at stop ID ' + sid);
getNextBus(sid);
document.getElementById('scratchpad').innerHTML = '<div>' + sid + '</div>';
}
Hope this is useful.