Reputation:
I am facing this issue:
<p class="pushButton">
<a href="javascript:return;"
onclick="SetOkCodeButton('=SC_ORDER', 'BBPForm', '', '','');
return false;" name="Order" class="pushButton"
title="Orders your shopping cart. This completes the operation "
onmouseover="status=' ';return true;" onmouseout="status=' ';">
Order
</a>
</p>
<p class="pushButton">
<a href="javascript:return;"
onclick="SetOkCodeButton('=SC_REFRESH', 'BBPForm', '', '','');
return false;" name="Refresh" class="pushButton"
title="Updates all details according to your changes. "
onmouseover="status=' ';return true;" onmouseout="status=' ';">
Refresh
</a>
</p>
I need to change the functionality of the ORDER button. It should trigger the REFRESH
(generating the SC_REFRESH
event) functionality right before the SC_ORDER
event is generated.
It means I need to trigger two events with one onlick
on the ORDER button - first REFRESH
and then ORDER
. With 2 second time break between the two events.
The functionality of REFRESH
will not change.
Upvotes: 0
Views: 3422
Reputation:
I just found out that the code I listed here is generated by this template from SAP. I am new in this. :-) Anybody can see a chance to trigger 2 events (SC_REFRESH and SC_ORDER) instead of just one (SC_ORDER)?
TR()
TD()
BBPVSpace()
BBPButtonBegin()
if (BTN_SC_ORDER.exists)
if (BTN_SC_ORDER.disabled)
BBPDisabledButton(BTN_SC_ORDER.label)
BBPButtonSpace()
else
BBPButton(BTN_SC_ORDER.OKCODE,BTN_SC_ORDER.label, tooltip=#BUTTON_ORDER)
BBPButtonSpace()
end
end
if (BTN_SC_REFRESH.exists)
if (BTN_SC_REFRESH.disabled)
BBPDisabledButton(BTN_SC_REFRESH.label)
BBPButtonSpace()
else
BBPButton(BTN_SC_REFRESH.OKCODE,BTN_SC_REFRESH.label,tooltip=#BUTTON_ACTUAL)
BBPButtonSpace()
end
end
Upvotes: 0
Reputation: 1669
Any reason this won't work?
<p class="pushButton">
<a href="javascript:return;"
onclick="SetOkCodeButton('=SC_REFRESH', 'BBPForm', '', '','');SetOkCodeButton('=SC_ORDER', 'BBPForm', '', '','');
return false;" name="Refresh" class="pushButton"
title="Updates all details according to your changes. "
onmouseover="status=' ';return true;" onmouseout="status=' ';">
Refresh
</a>
</p>
If those functions are synchronous, this should be OK, if they're async, you'll likely need a callback.
Upvotes: 1
Reputation: 75872
A). What's the reason for the 2-sec delay? This is extremely suspicious...
B). Any given method should achieve exactly one thing well. Creating different functionality for REFRESH and ORDER within the method suggests to me that you really have two methods which should be broken into two (which perhaps both call a common third function), but then again I'm struggling to imagine why you would want to refresh the form before posting it.
C). If you really need this you can introduce a timer with setTimeout preferably into the newly divided method itself, but if you continue with the existing implementation then I guess in the onclick attribute itself, though now it gets messy(er). You'd write something like this:
onclick="SetOkCodeButton('=SC_REFRESH', 'BBPForm', '', '',''); setTimeout(function(){SetOkCodeButton('=SC_ORDER', 'BBPForm', '', '','');},2000);"
Note though that setTimeout is asynchronous - if you want a real wait() method you'll need to write one yourself (and these are processor expensive), but they're expensive and again I doubt you really need it.
D). The return false is also deeply suspicious...
E). Likewise with the mouseouts and overs, is this auto-generated code?
Upvotes: 2