FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Mar 6, 2012, 5:45 AM
10 Posts

Unable to click label using CSJS

  • Category: Dojo and Client Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 2
Hello all,
 
It looks like there is a difference in how the various clients handle clicking of items on the page. 
 
The attached code contains a keypress event handler, which will click an element on the page, depending on the key pressed. The DOWN_ARROW clicks the label and the UP_ARROW clicks the button. When executed in Firefox or IE, both events fire correctly, while the Notes client and Chrome can't seem to find the click method for the label. Lotus Notes reports an error like:
 

dojo.query("*[id$='label1']")[0].click is not a function

 

Shouldn't this work across all clients?

 
Thanks,
Alex Rasmussen
 
 
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:inputText id="input1" value="#{viewScope.input1}">
    </xp:inputText>
    <xp:br></xp:br>
    <xp:button id="button1" value="Button">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="input1">
            <xp:this.action><![CDATA[#{javascript:viewScope.input1 = "Button1 Click!"}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>

    <xp:br></xp:br>
    <xp:label value="Label1" id="label1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="input1">
            <xp:this.action><![CDATA[#{javascript:viewScope.input1 = "Label1 Click!"}]]></xp:this.action>
        </xp:eventHandler></xp:label>
    <xp:br></xp:br>
    <xp:eventHandler event="onClientLoad" submit="false">
        <xp:this.script><![CDATA[dojo.connect( document, 'keypress', function(e){
   
       if(e.keyCode == dojo.keys.DOWN_ARROW)
       {
          dojo.query("*[id$='label1']")[0].click();
          e.preventDefault();
       };
      
       if(e.keyCode == dojo.keys.UP_ARROW)
       {
          dojo.query("*[id$='button1']")[0].click();
          e.preventDefault();
       };
       
 }) ;]]></xp:this.script>
    </xp:eventHandler></xp:view>

 
 
 
Mar 8, 2012, 11:58 AM
10 Posts
Re: Unable to click label using CSJS
Nobody??

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.