我正在寻找比较Ember.js和Backbone.js的信息,以便与Ruby on Rails后端一起使用.有没有人有使用这两个客户端框架的经验,并愿意提供一些有关它们的见解?
我有一个Homeview,其中包含一些页面上的子视图,当我使用路由器导航到另一个页面时,如何清理现有视图,并为我要导航到的页面构建新视图?
此应用程序没有模型/集合,只有视图.
谢谢!
部分代码:
Home = Backbone.View.extend({
template: "static/js/templates/home.html",
initialize: function() {
_.bindAll(this);
this.render();
},
render: function() {
var view = this;
// Fetch the template, render it to the View element and call done.
namespace.fetchTemplate(this.template, function(tmpl) {
view.el.innerHTML=tmpl();
view.subRender();
});
return this;
},
subRender: function() {
var view = this;
var videoView = new Subview1({
el: $('#wrapper1'),
homeView: view
});
var timeView = new Subview2({
el: $("#wrapper2")
});
}
});
Run Code Online (Sandbox Code Playgroud) 我正在运行Mac OS 10.6,Java 1.6_17,Scala 2.8.1 final.我正在尝试使用Skype4Java进行简单的Skype通话,方法如下:
$>export JAVA_OPTS=-d32
$>scala -classpath .:./skype/release/skype.jar
scala> com.skype.Skype.makeCall("echotest")
Run Code Online (Sandbox Code Playgroud)
我收到了错误
"invalid attempt to access memory at location 0x0 ... bus error".
Run Code Online (Sandbox Code Playgroud)
有没有人经历过这个并找到解决方案?
注意:当我使用命令行java运行它时,我可以通过调用其中一个示例来完美地使用此api.尝试使用命令行scala执行相同的示例失败,并显示上述错误.
据我所知,可以使用Mongoose(源)对填充的文档进行排序.
我正在寻找一种方法来按一个或多个填充字段对查询进行排序.
考虑这两个Mongoose模式:
var Wizard = new Schema({
name : { type: String }
, spells : { [{ type: Schema.ObjectId, ref: 'Spell' }] }
});
var Spell = new Schema({
name : { type: String }
, damages : { type: Number }
});
Run Code Online (Sandbox Code Playgroud)
示例JSON:
[{
name: 'Gandalf',
spells: [{
name: 'Fireball',
damages: 20
}]
}, {
name: 'Saruman',
spells: [{
name: 'Frozenball',
damages: 10
}]
}, {
name: 'Radagast',
spells: [{
name: 'Lightball',
damages: 15
}] …Run Code Online (Sandbox Code Playgroud) 如何在Rails 3中存储和处理网站用户的地理位置(long和lat),以便检查我们是否已经在每个页面请求中为该用户的会话中保留这些详细信息(如果我们是没有详细信息,那么我们应该从浏览器请求用户的位置,然后将这些详细信息存储在会话中)?
假设我有一系列对象
[{href: 'some_uri', 'class': 'this-css-class'}, {href: 'another_uri', 'class': 'that-css-class'}]
我现在想将其映射到html列表:
<ul>
<li class="this-css-class"><a href="some_uri">some_uri</a></li>
<li class="that-css-class"><a href="another_uri">another_uri</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
假设我向我的数组中添加了另一个对象,我想<li>在列表中添加一个新对象.相反,当我$('.that-css-class').remove()列出其中一个列表项时,我希望它也可以在数组中消失.
我想把它保存在jQuery中,因为我不想在项目中引入另一个框架.
非常感谢,这一直在我的脑海中.谢谢.
假设我有一个显示基于属性的视图的模板:
{{#if App.contentsAreVisible}}
{{view ToggleContents}}
{{/if}}
Run Code Online (Sandbox Code Playgroud)
通过设置,可以通过UI的任意数量的其他部分切换此区域 App.set("contentsAreVisible", [true/false]);
一切正常.
但是,我现在想要在切换视图时进行动画处理.连接didInsertElement到动画显示区域的工作,但我不能这样做willDestroyElement因为在动画有机会运行之前,该函数返回后立即删除元素.
App.ToggleContents = Ember.View.extend({
// this works fine
didInsertElement: function(){
this.$().hide().show("slow");
},
// this doesn't work
willDestroyElement: function(){
this.$().hide("slow", function(){
// animation is complete, notify that the element can be removed
});
}
});
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉视图推迟从DOM中删除元素,直到动画完成?
这是一个互动示例的小提琴:http://jsfiddle.net/rlivsey/RxxPU/
也许我在某个地方的文档中错过了这个但是这里.我有一个负责管理模块的核心控制器.到目前为止,我有大约20个模块,并且希望能够轻松地将它们配置为由核心加载.这意味着我需要大量的数组或大量的调用.在文字对象中创建模块列表然后让模块从中加载它的依赖项是否可接受/良好实践?这是我的意思的一个例子:
Config.js
modules = [
'moduleA',
'moduleB',
'moduleC'
];
Run Code Online (Sandbox Code Playgroud)
Core.JS
define(
['config'],
function(config) {
// Somewhere in here I parse the list and require() each one ?
return {
startAll : function() {
console.log('starting all modules.');
// Then call a method common to all 'modules' in the list above.
}
}
};
}
);
Run Code Online (Sandbox Code Playgroud)
我不确定这是一个好主意,因为我是RequireJS的新手,但我喜欢能够配置从一个地方加载哪些模块的想法.在我的模块中,我指的是我更具体地编写的UI小部件.
我有一个打开弹出窗口的页面
openWindow(top, 'prcsTypeSelectionPopup?event=prcsTypeSelection', 'lovWindow', {width:750, height:550}, true, 'dialog', pathCallBack);
Run Code Online (Sandbox Code Playgroud)
并且弹出窗口具有以下代码
function returnSelect()
{
window.document.forms[0].choice_processType.value ;
window.opener.document.forms[0].pevent.value = 'getprocessName';
window.opener.document.forms[0].processName.value='';
for (var i=0; i < document.forms[0].elements.length; i++)
{
if (document.forms[0].elements[i].checked)
{
window.opener.document.forms[0].processName.value=document.forms[0].elements[i].value;
break;
}
}
if(window.opener.document.forms[0].processName.value=='') {
window.opener.document.forms[0].lovProcessType.value = '';
window.opener.document.forms[0].pevent.value = '';
}
window.opener.document.forms[0].submit();
closeConn();
}
function closeConn()
{
self.close();
}
Run Code Online (Sandbox Code Playgroud)
但是当页面加载到firefox中时,我得到错误,因为window.opener在returnselect()函数的第二行是null
function returnSelect()
{
window.document.forms[0].choice_processType.value ;
--> window.opener.document.forms[0].pevent.value = 'getprocessName';
Run Code Online (Sandbox Code Playgroud)
任何想法如何克服这一点
提前致谢...
javascript ×5
backbone.js ×2
ember.js ×2
jquery ×2
ajax ×1
cakephp ×1
dependencies ×1
dom ×1
firefox ×1
geolocation ×1
html5 ×1
java ×1
macos ×1
mongodb ×1
mongoose ×1
node.js ×1
php ×1
requirejs ×1
scala ×1
skype4java ×1
sorting ×1
symfony1 ×1