2016-11-05 9 views
1

OpenUI5のヘルプが必要です。ビューにボタンを作成し、ボタンをクリックするとダイアログウィンドウが作成され、エラーがスローされるので、ダイアログの機能に進むことはできません。ビュー内のOpenUI5でダイアログを作成するときに重複するID

ボタン:コントローラで

<m:Button text="{i18n>RESULTS_CHANCES_SEND_EMAIL}" 
      class="sapUiMediumMarginBegin results-button" 
      tap="sendToEmail" 
      press="sendToEmail" 
      icon="sap-icon://email"> 

機能:

sendToEmail: function() { 

    var email = new Dialog({ 
     title: 'שליחת תוצאות לדוא"ל', 
     type: 'Message', 
     content: [ 
     new Input('submitEmailInput', { 
      liveChange: function (oEvent) { 
      var sText = oEvent.getParameter('value'); 
      var parent = oEvent.getSource().getParent(); 

      parent.getBeginButton().setEnabled(sText.length > 0); 
      }, 
      width: '100%', 
      placeholder: 'דואר אלקטרוני' 
     }) 
     ], 
     beginButton: new Button({ 
     text: 'שליחה', 
     enabled: false, 
     icon: 'sap-icon://email', 
     press: function() { 

      //var sText = sap.ui.getCore().byId('submitEmailInput').getValue(); 
      //MessageToast.show('Email is: ' + sText); 

      // here comes the API request 
      email.close(); 
     } 
     }), 
     endButton: new Button({ 
     text: 'סגירה', 
     icon: 'sap-icon://decline', 
     press: function() { 
      email.close(); 
     } 
     }), 
     afterClose: function() { 
     email.destroy(); 
     } 
    }); 

    email.open();} 

エラー:duplicate id

多くの感謝!

+0

私は現時点でUI5を勉強しています。私は破壊がDOMのHTML要素を残すかもしれないどこかを読んでいると思う。多分、フラグメントや破棄の使用に関連する他のケースのためにgoogle。 –

答えて

0

sendToEmailが2回呼び出されるように(同じIDを持つコントロールが既に存在する)、同じイベントハンドラを「タップ」および「プレス」イベントに関連付けました。これは「タップ」を削除します減価償却されるので、あなたは次のようになるはずです。

<m:Button text="{i18n>RESULTS_CHANCES_SEND_EMAIL}" 
     class="sapUiMediumMarginBegin results-button" 
     press="sendToEmail" 
     icon="sap-icon://email"> 
関連する問題