我的UI5应用中有一个元素。我想要做的是将日期粘贴到其中,然后在按下按钮时读取它。问题是它只适用于Chrome和Firefox,但不适用于我需要它的IE。当我从div读取数据IE时没有正确读取换行符和标签,因此我无法正确解析数据。
这是我的包含div
的xml视图代码<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
height="100%"
xmlns:html="http://www.w3.org/1999/xhtml"
controllerName="sap.m.sample.Button.Page">
<Page
class="sapUiContentPadding" >
<content>
<HBox>
<Button type="Accept"
text="Accept"
press="onPress"
ariaDescribedBy="acceptButtonDescription genericButtonDescription">
</Button>
</HBox>
</content>
<FlexBox direction="Column" alignItems="Center">
<html:div id="divinput" contenteditable="true" ><html:i>something</html:i> text</html:div>
</FlexBox>
</Page>
这是我的控制器,我抓取数据并解析它
sap.ui.define(['sap/m/MessageToast','sap/ui/core/mvc/Controller'],
function(MessageToast, Controller) {
"use strict";
var PageController = Controller.extend("sap.m.sample.Button.Page", {
onPress: function (evt) {
var divInput = this.getView().byId("divinput").getDomRef();
//var inputA = this.getView().byId("input").getDomRef().innerHTML;
var x = divInput.innerText;//innerHTML;
var data = [];
var rows = x.split("\n");
for(var i=0; i<rows.length; i++){
var row = rows[i].split("\t");
var obj = {NSN: row[0], QTY: row[1]};
data.push(obj);
}
//now update the data with formatting
this.updateData(data);
},
updateData: function(data){
var div = this.getView().byId("divinput").getDomRef();
var text = "";
for(var i = 0; i<data.length; i++){
if(data[i].NSN == "000123456"){
text += "<b>" + data[i].NSN + "</b> " + data[i].QTY +"<br>"; //there is no tab tag in html, use 4 spaces instead
}
else{
text += data[i].NSN + " " + data[i].QTY +"<br>";
}
}
div.innerHTML = text;//"<i>something</i>, <b>something</b>";
}
});
return PageController;
});