我正在使用简单的路由创建sapui5示例应用程序(sapui5/openui5版本为1.22).
我的主要问题,我试图理解,为什么url模式更改和目标视图控制器的onInit被触发,但没有任何反应(onAfterRendering未触发),我只能在页面重新加载后转到另一个页面.
路由设置:
初始化路由器的Compontent.js按以下方式构造:
sap.ui.define([
"sap/ui/core/UIComponent"
], function (UIComponent) {
return UIComponent.extend("sge.apps.app.Component", {
metadata:{
name : "Sample App",
version : "1.0",
includes : [],
dependencies : {
libs : ["sap.m", "sap.ui.layout"],
components : []
},
rootView: "sge.apps.app.view.App",
config: {
resourceBundle: "i18n/i18n.properties"
},
routing : {
config : {
routerClass : sap.ui.core.routing.Router,
viewType : "XML",
viewPath : "sge.apps.app.view",
targetControl: "app",
targetAggregation: "pages",
transition: "slide",
clearTarget : false,
bypassed: {
target: "notFound"
}
},
routes: [{
pattern: "",
name: "appHome",
view: "Home" …Run Code Online (Sandbox Code Playgroud) 我有以下MVC4应用程序结构:
从Index.cshtml我试图对位于我的HomeController.cs中的SomeActionMethod()进行ajax调用
Index.cshtml看起来像:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/jquery-2.2.2.min.js"></script>
</head>
<body>
<script>
$.ajax({
url: '@Url.Action("SomeActionMethod", "HomeController")',
type: "POST",
cache: false,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (data) {
alert(data);
},
error: function () {
alert("fail");
}
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
HomeController.cs看起来像:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace SapRepLanciatoreCAS.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
//trying to invoke from ajax
[HttpPost]
public ActionResult SomeActionMethod()
{
return …Run Code Online (Sandbox Code Playgroud) 我想用ASP .Net触发jQuery更改事件.这是ASP和jQuery代码的一部分:
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="body">
<p>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</p>
<script type ="javascript">
$('#DropDownList1').change(function() {
alert( "Handler for .change() called." );
});
</script>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)
试图通过id#body_DropDownList1和#DropDownList1来获取元素.不幸的是,两种情况都没有输出.