问题标签 [hottowel]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
977 浏览

durandal - Hot Towel SPA Modal Dialog 敲除绑定和验证

我正在使用 Hot Towel SPA 模板构建 SPA。
这是我的问题:
我有一个视图,我将与场地相关的信息(名称、描述、地址等)与场地相关联,有不同的房间有自己的字段(名称、描述、类型等)我有一个房间列表和一个“添加新房间”按钮。
当我点击按钮时,会弹出一个模式对话框,我用请求的信息填写表单,然后保存。对话框关闭后,列表会更新。我可以从对话框中检索信息,但如果字段留空,我将无法触发验证规则。datacontext.HasChanges()
也总是返回 true。是否可以像使用任何其他视图一样使用模态对话框?
这是我正在使用的代码的一部分:
来自Model.cs

来自场地详情.js

来自 roommodal.js:

roommodal.html

任何帮助将不胜感激。提前致谢。

0 投票
2 回答
441 浏览

c# - SPA(热毛巾) - 如何更改约定以处理/请求 Razor 视图?

以 Hot Towel SPA 模板为例,假设我需要一个管理员链接和视图,该链接仅对具有管理员角色的登录用户显示。应该很简单吧?

使用 Razor(或 WebForms 或其他任何东西,实际上并不重要)视图,在 nav.cshtml 中包含它是一件简单的事情:

并对 ViewsController 进行操作,例如:

肯定可以更改约定,例如,Widget 的路由查找http://server/Views/widget而不是http://server/App/views/widget.htm(可能是选择性地?)禁用视图请求的缓存。

在我看来,主要的替代方案是公开不应公开给从浏览器查看页面源代码的任何人的内容。如果不应该显示某些内容,我宁愿根本不将其包含在 HTML 输出中,也不愿将其全部发送下来并有选择地隐藏/显示客户端。

0 投票
1 回答
659 浏览

kendo-ui - Using durandal with jaydata and kendoui

I created a new VS2012 project using the hottowel template, which in return uses durandal, knockout and breeze.

I want to use jaydata instead of breeze and for the ui layer I want to use the excellent asKendoDataSource() functionality to power a kendoui grid.

I followed all the instructions to make kendoui work well with durandal. This is fine.

I have a model in which I get the jaydata entities and run asKendoDataSource() on it. My view is an MVVM declared kendoui grid with its source property set to the viewmodel's property that contains a reference to the asKendoDataSource().

In the knockout world the viewModel property would be an empty entities = ko.observableArray() which would then would be initialized by using entities(values) when the data service returns.

I need to mimic this such that I have a viewModel property that is an empty kendo datasource which then is initialized by the asKendoDataSource() conversion when the data comes back from jaydata. This way the mvvm kendo grid is bound initially to the empty datasource and then receives its items when the asKendoDataSource() is called.

This is all because the model - viewModel binding in durandal is asynchronous and there needs to be a placeholder property in the viewModel from the very beginning, which then, after the viewModel's activate() method promise is resolved, gets updated with the bound data and in return powers the DOM that the viewModel is bound to.

I can't figure out how to mimic the knockoutjs practice of an empty observable array which is bound to the dom and then (the same exact reference) gets initialized and populates the dom. There seems to be no way to create an empty kendo datasource which then is re-initialized by the asKendoDataSource() method. Reassigning the viewModel property to the new data source doesn't work because the kendo grid is bound to the original reference.

This is my airport view:

This is my datacontext:

This is my airport viewmodel:

One last issue that I am seeing: It seems to me that an MVVM declared kendoui grid, bound to the view model through data-kendo-bind={source: airports)" where airports is a property of the viewmodel that was created through entities.asKendoDataSource() does not work. Somehow the grid does not show the data. Is there something extra that needs to be done?

Thanks

0 投票
1 回答
471 浏览

javascript - 使用敲除绑定选择 html 控件

我正在使用微风 + 淘汰赛作为基础热毛巾模板。使用此模板,我可以进行一些绑定,例如:

其中 rolelist 是一个 ko.observableArray() ,而 role 是一个字符串属性。这个例子一切都很好。

当我尝试进行一些更复杂的数据绑定时,我的问题就开始了,即:

在这个新示例 mycollection 中,它是 ko.observableArray() 和 dictionary().name(),它是“对象属性”加上一个字符串属性。如果我去 chrome 调试器,我可以看到 mycollection()[0].dictionary().name() 有一个值。

所以我不知道我做错了什么。这是一个简短的例子(你可以看到我只使用 dictionary.name)http://jsfiddle.net/rolandomartinezg/BN2ZP/2/

0 投票
1 回答
3544 浏览

knockout.js - Breeze 使用 moment.js 检索的格式化日期。热毛巾模板

我一直在关注 John Papa 的热毛巾教程,并且我的 ac# 类看起来像这样:

我正在使用微风检索客户端中的数据,但我无法弄清楚如何使用 moment.js 和 knockout.js 格式化日期。当我使用以下敲除绑定显示未格式化的日期时:

日期以下列格式显示:

当我尝试使用 moment.js 格式化它们时,如下所示:

结果输出如下所示:

我还尝试通过执行以下操作在位于我的模型中的 LeadInitializer 中进行格式化(这是我更喜欢的):

这样做,我仍然得到相同的输出:

我读过这篇文章

Knockout 的日期格式问题和同步到微风.js entityAspect 已修改

但这似乎对我没有帮助。有人可以告诉我哪里出错了吗?

0 投票
2 回答
2400 浏览

kendo-ui - KendoUI DataSource 绑定到 durandal 中的 MVVM 网格(使用热毛巾模板)似乎不起作用

我正在使用带有更新的 durandal 和 jquery nuget 包的 Visual Studio 2012 Update 2 hottowel 模板...

这是我的代码:Durandal main.js:

杜兰达尔视图模型:

杜兰达尔观点:

我在 Chrome 的网络监视器中看到对 jaystack 的调用: https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase//Airport? $inlinecount=allpages&$top=25 我看到数据回来了。

kendoui 网格创建得很好,但其中没有数据(我认为这意味着 kendoui 很高兴并且绑定了 MVVM 绑定,但是创建的 kendoui 网格似乎不想理解从 jaydata 创建的 kendoui 数据源)

如果没有 durandal,这可以很好地工作,如下所示:http: //jsfiddle.net/t316/4n62B/29/

我已经尝试了 2 天了 - 有人可以帮我吗?

谢谢TJ

0 投票
1 回答
888 浏览

javascript - 如何将 list.js 与热毛巾模板一起使用

我正在使用热毛巾模板,并且正在尝试使用 list.js 过滤列表中的结果。

我已经在我的包配置中包含了 list.min.js 文件,并且我也在 index.html 文件中正确地引用了它。

我有一个看起来像这样的视图(leads.html):

然后我有一个对应的 viewModel (leads.js),如下所示:

当我运行应用程序时,我的列表会正确填充,但是当我在搜索输入中输入任何内容时,不会发生过滤。我觉得我错过了 KnockoutJS 特有的一些东西,以及我正在使用 observables 的事实。

我也不确定我视图末尾的脚本是否真的应该在我的视图模型中?

任何帮助将不胜感激。谢谢!

0 投票
1 回答
700 浏览

hottowel - Hot Towel 如何处理身份验证和个性化?

我真的很喜欢 Hot Towel 背后的概念,并且已经看过 Pluralsight 上的课程几次,以便真正了解正在发生的事情。

Hot Towel 的一个方面确实让我难以理解——它如何用于需要不同用户角色的应用程序?课程中没有涉及身份验证和个性化的主题,并且似乎没有任何简单的方法可以通过修改框架本身来完成此任务。

0 投票
1 回答
533 浏览

sammy.js - 如何在 Durandal SPA 中自定义 mapNav() 函数

我在 Hot Towel SPA 模板中使用以下内容

如果我只是想覆盖路线的名称属性(出现在导航栏中),我将如何提供这个?

我找到了这个例子

});

我是否需要提供所有其他参数来修改 name 属性?

干杯

0 投票
1 回答
173 浏览

model-view-controller - umbraco content integration into hot towel spa web app

I have an old website that displays content from umbraco per page. This is done by using a pageload to call a webservice and render umbraco html content to a literal control. i.e.

How would I accomplish this same rendering but in a MVC way for a hot towel spa application. How should this be structured per view when a single page application is designed to load most content at start?