1

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 &amp;&amp; window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" 
    onclick="if (window.sfdcPage &amp;&amp; window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" 
    ondblclick="if (window.sfdcPage &amp;&amp; window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" 
    onfocus="if (window.sfdcPage &amp;&amp; window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" 
    onkeypress="if (window.sfdcPage &amp;&amp; window.sfdcPage.hasRun &amp;&amp; event &amp;&amp; event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" 
    onmouseout="if (window.sfdcPage &amp;&amp; window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" 
    onmouseover="if (window.sfdcPage &amp;&amp; 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>
Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
Charlie
  • 59
  • 1
  • 8

2 Answers2

0

You can accomplish this by calling apply, as in this answer here:

How can I programmatically invoke an onclick() event from a anchor tag while keeping the ‘this’ reference in the onclick function?

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/

Community
  • 1
  • 1
Ethan Brown
  • 26,892
  • 4
  • 80
  • 92
  • Um...well, I'm not really sure how using Chrome's console will accomplish anything here. I mean, you can enter a function into the console, but you can't really declare HTML (easily, at any rate), so you couldn't hook up your double-click header.... Let me throw a jsfiddle at you; hopefully that'll make it clear. – Ethan Brown Jul 02 '13 at 04:07
0

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>
Lee Taylor
  • 7,761
  • 16
  • 33
  • 49