2016-10-14 9 views
1

ラジオボタングループの選択に従って値をリフレッシュするリストボックスコントロールです。リストボックスは、スコープ変数配列をソースとして使用します。だからラジオボタンをクリックすると、リストボックスの値を変更したい。 1回目/ 2回目のクリック後に動作し、リストボックスをリフレッシュせずに再び動作します。私は間違って何をしていますか?xPagesラジオボタングループのonchangeイベントが機能しない

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

<xp:this.beforePageLoad><![CDATA[#{javascript:viewScope.MYARRAY = new Array(); 
viewScope.MYARRAY.push(["NAME1", "ID1"]); 
viewScope.MYARRAY.push(["NAME2", "ID3"]); 
viewScope.MYARRAY.push(["NAME3", "ID4"]); 
viewScope.MYARRAY.push(["NAME4", "ID5"]);}]]> 
</xp:this.beforePageLoad> 

<xp:radioGroup id="radioGroupSortBy" defaultValue="0"> 
    <xp:selectItem itemLabel="by Name" itemValue="0"></xp:selectItem> 
    <xp:selectItem itemLabel="by Id" itemValue="1"></xp:selectItem> 
     <xp:eventHandler event="onchange" submit="true" 
      refreshMode="partial" refreshId="listBox1"> 
     </xp:eventHandler> 
     <xp:eventHandler event="onclick" submit="true" 
      refreshMode="partial" refreshId="listBox1"> 
     </xp:eventHandler> 
</xp:radioGroup> 

<xp:listBox id="listBox1" style="width:390.0px;height:166.0px"> 
    <xp:selectItems> 
     <xp:this.value><![CDATA[#{javascript:var arr = new Array(); 
      for(var i=0; i<viewScope.MYARRAY.length; i++){ 
       if(getComponent("radioGroupSortBy").getValue()==0){ 
        arr.push(viewScope.MYARRAY[i][0] + " - " + viewScope.MYARRAY[i][1]); 
       } else { 
        arr.push(viewScope.MYARRAY[i][1] + " - " + viewScope.MYARRAY[i][0]); 
       } 
      } 
      return arr.sort();}]]> 
     </xp:this.value> 
    </xp:selectItems> 
</xp:listBox> 
</xp:view> 

答えて

1

あなたの例では動作しませんが、それは「ワンクリック遅すぎる」ラベルをクリックした場合です。

This is an onClick partial refresh bug with radio buttons

onClickイベントに次のCCJSコードを追加します。

<xp:eventHandler event="onclick" submit="true" 
     refreshMode="partial" refreshId="listBox1"> 
     <xp:this.script><![CDATA[ 
      var e = arguments[0] || window.event; 
      e = dojo.fixEvent(e); 
      if (e.target.type != "radio") { 
       e.preventDefault(); 
       dojo.query("input",e.target).forEach(function(inputNode){ 
        dojo.attr(inputNode,"checked",!(dojo.attr(inputNode,"checked"))); 
       }); 
      } 
      return true; 
     ]]></xp:this.script> 
    </xp:eventHandler> 
0

ラジオボタンのイベントは、特定のブラウザ(IE)で奇妙なことがあります。 xspプロパティファイルにこの設定がありますか?

http://www-01.ibm.com/support/docview.wss?uid=swg21631834

のonclickと変化の両方を使用しないでください。あなたはラジオenter image description here自体をクリックした場合

ハワード

関連する問題