输入事件 suggestionItemSelected 不触发
Input event suggestionItemSelected not fire
我有一个输入组件:
<Input
value=""
showSuggestion="true"
showValueHelp="true"
valueHelpOnly="true"
valueHelpRequest="handleValueLocalHelp"
suggestionItemSelected="onLiveChangeSimple"
/>
这是我的职能:
onLiveChangeSimple: function (oEvent) {
console.log("OK!")
},
当我点击输入时,我会在帮助对话框中显示建议项;然后我 select 一项和输入值正确更改 但 onLiveChangeSimple
不触发 !为什么?
如果我在这种模式下修改输入:
<Input
value=""
liveChange="onLiveChangeSimple"
/>
onLiveChangeSimple
开始...
当我点击“帮助”对话框中的项目时触发的事件是什么?
应该没问题...但我注意到您没有在 Input
控件中指定聚合 suggestionItems
,您是否以不同的方式管理事情?
<Input
id="productInput"
type="Text"
placeholder="Enter Name ..."
showSuggestion="true"
suggestionItems="{/}"
suggestionItemSelected="suggestionItemSelected">
<suggestionItems>
<core:Item text="{name}" />
</suggestionItems>
</Input>
请参阅下面的工作示例,了解如何触发 suggestionItemSelected
事件:
jQuery.sap.require("sap.m.MessageBox");
sap.ui.controller("view1.initial", {
onInit : function(oEvent) {
var aData = [
{name: "Dente, Al", userid: "/c01/b2/u3/u44"},
{name: "Friese, Andy", userid: "/a01ss/a2/u3/u44"},
{name: "Mann, Anita", userid: "/U013333/u2/u3/u44"},
{name: "Schutt, Doris", userid: "/U01/u2/u3/u44"},
{name: "Open, Doris", userid: "/U01/u2/u3/u44"},
{name: "Dewit, Kenya", userid: "/U01/u2/u3/u44"},
{name: "Zar, Lou", userid: "/U01/bu2/u3/u44"},
{name: "Burr, Tim", userid: "U08"},
{name: "Hughes, Tish", userid: "U09"},
{name: "Town, Mo", userid: "U10"},
{name: "Case, Justin", userid: "U11"},
{name: "Time, Justin", userid: "U12"},
{name: "Barr, Sandy", userid: "U13"},
{name: "Poole, Gene", userid: "U14"},
{name: "Ander, Corey", userid: "U15"},
{name: "Early, Brighton", userid: "U16"},
{name: "Noring, Constance", userid: "U17"},
{name: "O'Lantern, Jack", userid: "U18"},
{name: "Tress, Matt", userid: "U19"},
{name: "Turner, Paige", userid: "U20"}
];
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(aData);
this.getView().setModel(oModel);
},
suggestionItemSelected: function(oEvent) {
sap.m.MessageBox.show("Selected " + oEvent.getParameter("selectedItem").getBindingContext().getObject().name);
}
});
var oView = sap.ui.xmlview({
viewContent: jQuery("#view1").html()
});
oView.placeAt("uiArea");
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>SAPUI5 template</title>
<style>
.sapUiUfdShellBackground, .sapMGlobalBackgroundColor {
background-color: transparent !important;
background-image: none !important;
}
.sapMShellGlobalInnerBackground {
background-image: none !important;
}
</style>
<script id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-libs="sap.m"></script>
<script id="view1" type="ui5/xmlview">
<mvc:View
height="100%"
controllerName="view1.initial"
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
xmlns="sap.m">
<Input
id="productInput"
type="Text"
placeholder="Enter Name ..."
showSuggestion="true"
suggestionItems="{/}"
suggestionItemSelected="suggestionItemSelected">
<suggestionItems>
<core:Item text="{name}" />
</suggestionItems>
</Input>
</mvc:View>
</script>
</head>
<body class="sapUiBody" role="application">
<div id="uiArea"></div>
</body>
</html>
问题是我在哪里插入项目选项。我不使用 suggestionItems 聚合,而是使用 SelectDialog https://openui5.hana.ondemand.com/explored.html#/entity/sap.m.SelectDialog/samples
我有一个输入组件:
<Input
value=""
showSuggestion="true"
showValueHelp="true"
valueHelpOnly="true"
valueHelpRequest="handleValueLocalHelp"
suggestionItemSelected="onLiveChangeSimple"
/>
这是我的职能:
onLiveChangeSimple: function (oEvent) {
console.log("OK!")
},
当我点击输入时,我会在帮助对话框中显示建议项;然后我 select 一项和输入值正确更改 但 onLiveChangeSimple
不触发 !为什么?
如果我在这种模式下修改输入:
<Input
value=""
liveChange="onLiveChangeSimple"
/>
onLiveChangeSimple
开始...
当我点击“帮助”对话框中的项目时触发的事件是什么?
应该没问题...但我注意到您没有在 Input
控件中指定聚合 suggestionItems
,您是否以不同的方式管理事情?
<Input
id="productInput"
type="Text"
placeholder="Enter Name ..."
showSuggestion="true"
suggestionItems="{/}"
suggestionItemSelected="suggestionItemSelected">
<suggestionItems>
<core:Item text="{name}" />
</suggestionItems>
</Input>
请参阅下面的工作示例,了解如何触发 suggestionItemSelected
事件:
jQuery.sap.require("sap.m.MessageBox");
sap.ui.controller("view1.initial", {
onInit : function(oEvent) {
var aData = [
{name: "Dente, Al", userid: "/c01/b2/u3/u44"},
{name: "Friese, Andy", userid: "/a01ss/a2/u3/u44"},
{name: "Mann, Anita", userid: "/U013333/u2/u3/u44"},
{name: "Schutt, Doris", userid: "/U01/u2/u3/u44"},
{name: "Open, Doris", userid: "/U01/u2/u3/u44"},
{name: "Dewit, Kenya", userid: "/U01/u2/u3/u44"},
{name: "Zar, Lou", userid: "/U01/bu2/u3/u44"},
{name: "Burr, Tim", userid: "U08"},
{name: "Hughes, Tish", userid: "U09"},
{name: "Town, Mo", userid: "U10"},
{name: "Case, Justin", userid: "U11"},
{name: "Time, Justin", userid: "U12"},
{name: "Barr, Sandy", userid: "U13"},
{name: "Poole, Gene", userid: "U14"},
{name: "Ander, Corey", userid: "U15"},
{name: "Early, Brighton", userid: "U16"},
{name: "Noring, Constance", userid: "U17"},
{name: "O'Lantern, Jack", userid: "U18"},
{name: "Tress, Matt", userid: "U19"},
{name: "Turner, Paige", userid: "U20"}
];
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(aData);
this.getView().setModel(oModel);
},
suggestionItemSelected: function(oEvent) {
sap.m.MessageBox.show("Selected " + oEvent.getParameter("selectedItem").getBindingContext().getObject().name);
}
});
var oView = sap.ui.xmlview({
viewContent: jQuery("#view1").html()
});
oView.placeAt("uiArea");
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>SAPUI5 template</title>
<style>
.sapUiUfdShellBackground, .sapMGlobalBackgroundColor {
background-color: transparent !important;
background-image: none !important;
}
.sapMShellGlobalInnerBackground {
background-image: none !important;
}
</style>
<script id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-libs="sap.m"></script>
<script id="view1" type="ui5/xmlview">
<mvc:View
height="100%"
controllerName="view1.initial"
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
xmlns="sap.m">
<Input
id="productInput"
type="Text"
placeholder="Enter Name ..."
showSuggestion="true"
suggestionItems="{/}"
suggestionItemSelected="suggestionItemSelected">
<suggestionItems>
<core:Item text="{name}" />
</suggestionItems>
</Input>
</mvc:View>
</script>
</head>
<body class="sapUiBody" role="application">
<div id="uiArea"></div>
</body>
</html>
问题是我在哪里插入项目选项。我不使用 suggestionItems 聚合,而是使用 SelectDialog https://openui5.hana.ondemand.com/explored.html#/entity/sap.m.SelectDialog/samples