Does anyone know what javascript function I could call to activate the 'dblClickField' event on this id without actually clicking the box? It's a checkbox and I want to force tick it through the console using javascript.
<td
class="dataCol inlineEditWrite"
id="00N200000030rph_ilecell"
onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"
onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);"
ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);"
onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);"
onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);"
onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"
onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);"
tabindex="0">
<div id="00N200000030rph_ileinner">
<img src="/img/checkbox_unchecked.gif" alt="Not Checked" width="21" height="16" class="checkImg" id="00N200000030rph_chkbox" title="Not Checked">
</div>
</td>
You can accomplish this by calling apply
, as in this answer here:
However, you might want to consider a slightly different approach. Just put your double-click handler in a function:
function onDoubleClick() {
if (window.sfdcPage && window.sfdcPage.hasRun)
sfdcPage.dblClickField(event, this);
}
Then you can just reference it from your <td>
element:
<td ondblclick="onDoubleClick();"...
And anywhere else you need to invoke it from as well.
Here's a jsfiddle to demonstrate: http://jsfiddle.net/nq5aP/
Don't put so much inline code into your HTML. It's not very easy to read. Put your code in a function, then you can call it whenever you like (without spoofing a double-click event):
<script>
function dblclickfunction(event)
{
if (window.sfdcPage && window.sfdcPage.hasRun)
sfdcPage.dblClickField(event, this);
}
</script>
<td
class="dataCol inlineEditWrite"
id="00N200000030rph_ilecell"
onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"
onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);"
ondblclick="dblclickfunction(event);"
onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);"
onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);"
onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"
onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);"
tabindex="0">
<div id="00N200000030rph_ileinner">
<img src="/img/checkbox_unchecked.gif" alt="Not Checked" width="21" height="16" class="checkImg" id="00N200000030rph_chkbox" title="Not Checked">
</div>
</td>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.