我点击按钮显示以下错误"Microsoft JScript运行时错误:对象不支持属性或方法'实时'" 我的查看页面如下:
@model Charis.Models.Products
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="../../Content/CharisSite.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
@using (Html.BeginForm("Create", "Prod", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
<table><tr><td>
<table>
<tr>
<td>
<fieldset>
<legend>Products</legend>
<table>
<tr>
<td>
<div class="editor-label">
@Html.LabelFor(model => model.Productname)
</div>
</td>
<td>
<div class="editor-field">
@Html.EditorFor(model => model.Productname)
@Html.ValidationMessageFor(model => model.Productname)
</div>
</td>
</tr>
<tr>
<td>
<div class="editor-label">
@Html.LabelFor(model => model.ProductPrice)
</div>
</td>
<td>
<div class="editor-field">
@Html.EditorFor(model => model.ProductPrice)
@Html.ValidationMessageFor(model => model.ProductPrice) …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个优雅,高效的解决方案来解决我的问题:
我有这个带有许多组件的webapp;
一个主要组成部分包括许多随时间增长/发展的新增内容.
这个主要组件有一个功能,在实际执行它应该做的事情之前,它会触发事件,然后插件可以监听.
dostg : function () {
$doc.trigger('beforedo');
//do stuff but after event is handled by the addons ?
}
Run Code Online (Sandbox Code Playgroud)
在插件代码中
$doc.on('beforedo',function(e) {
//do before addon stuff
}
Run Code Online (Sandbox Code Playgroud)
现在那些做事之前可能涉及ajax请求或任何需要一些处理时间的事情.
我可以在ajax请求上增加一个计数器并等待它降到零,但是我想要的是一个等待所有处理程序完成工作的解决方案(因此,无论在这些插件中做什么,它都能正常工作)处理程序).
是否有一些奇迹解决方案来做到这一点,或者我必须忘记在这种情况下的事件,并采取另一种方式(迭代的函数数组,插件将新函数推入数组)?
感谢您的专业知识!
-------编辑后的编辑
向@xbonez和@Sergiu Paraschiv道歉,在提供赏金之前,我应该用我现在使用的解决方案编辑问题(解决方案我并不完全满意,因此是赏金).
//app
var $doc = $(document.body);
//component
$doc.on({
wait: function (e) { ++$doc.component.handleinprogress; },
addonready: function () {
--$doc.component.handleinprogress;
if ($doc.component.handleinprogress==0) $doc.trigger('readyfordo');
},
readyfordo: function () {
//do stuff after event has been handled by the addons
}
});
$doc.component …Run Code Online (Sandbox Code Playgroud)