2016-11-05 54 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。我想我会在某个地方看到破坏可能会将HTML元素留在dom中。也许谷歌与其他案件相关的使用片段和销毁。 –

回答

0

你已经附加了相同的事件处理程序来“点击”和“按下”事件,所以sendToEmail被调用两次(并且第二次具有相同ID的控件已经存在)...删除“tap”,因为这是贬值,所以你最终应该:

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