将silverlight嵌入durandal
我有一个silverlight excel组件需要嵌入到我的durandal应用程序中 我的HTML看起来像:将silverlight嵌入durandal,silverlight,durandal,Silverlight,Durandal,我有一个silverlight excel组件需要嵌入到我的durandal应用程序中 我的HTML看起来像: <form id="silverlightControl" runat="server" data-bind="if: silverlightIsInstalled() && silverlightData()!=null"> <div id="silverlightControlHost"> <
<form id="silverlightControl" runat="server" data-bind="if: silverlightIsInstalled() && silverlightData()!=null">
<div id="silverlightControlHost">
<object id="silverlightObject" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%">
<param name="source" value="ClientBin/SilverlightGrid.xap" />
<param name="onError" value="onSilverlightError" />
<param name="onLoad" value="onSilverlightLoad" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="5.0.61118.0" />
<param name="autoUpgrade" value="false" />
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div>
</form>
问题是,这会尝试调用名为onSilverlightLoad和onSilverlightError的全局函数
在我的模块中是否有办法定义和覆盖这些全局函数
在我的模块中是否有办法定义和覆盖这些内容
全球功能
是的,你可以这样做
在全球范围内:
var currentModule = null;
function onSilverlightLoad(sender, args) {
if (currentModule && currentModule.onSilverlightLoad) {
// forward the event to the current module
currentModule.onSilverlightLoad(sender, args);
return;
}
// fallback logic...
}
function onSilverlightError(sender, args) {
if (currentModule && currentModule.onSilverlightError) {
// forward the event to the current module...
currentModule.onSilverlightError(sender, args);
return;
}
// fallback logic...
}
在您的模块中:
window.currentModule = this;
// todo: define public function properties named onSilverlightLoad and onSilverlightError
其他人将silverlight嵌入Durandal应用程序的提示 您需要这样做,否则当您离开该页面并返回到该页面时,会发生不好的事情: vm.binding=函数(){ 返回{cacheViews:false};
}; 替换为您自己的?可能的副本不是副本。请看上面的代码已经有了参数,但另一个问题并没有解决如何在require.js AMD模块中为durandal这样的单页应用程序框架定义此函数,在这些框架中,我不需要定义全局变量并用自己的变量替换。Silverlight上面的代码调用onSilverlightLoad函数,我拥有的每个AMD durandal模块都需要覆盖它,以便执行与当前页面相关的函数。因此。。。您想从JavaScript函数运行服务器端代码吗?请定义您的“模块”是什么。我确实理解为什么不将参数更改为自己的JavaScript函数并使用它运行。