可以说我有哈希哈希例如
$data = {
'harry' : {
'age' : 25,
'weight' : 75,
},
'sally' : {
'age' : 25,
'weight' : 75,
}
}
Run Code Online (Sandbox Code Playgroud)
我有点卡住实现了骨干比较器,我基本上想要根据路由选择不同的排序方法,并使用比较器对集合进行排序.理想情况下,我希望将排序逻辑封装在集合中,但似乎陷入困境.例如
Requests = Backbone.Collection.extend({
model : Request,
comparator : function(ab) {
return -ab.id;
},
nooffers : function() {
return this.sortBy(function(ab) {
return ab.get('offers');
});
}
});
Run Code Online (Sandbox Code Playgroud)
因此,默认情况下,它会根据默认比较器进行排序 - 但在我的路由中,我希望能够采取类似的措施
routes : {
"" : "index",
'/ordering/:order' : 'ordering'
},
ordering : function(theorder) {
ordering = theorder;
if(theorder == 'nooffers') {
Request.comparator = Request.nooffers();
}
Request.sort();
listView.render();
howitworksView.render();
}
Run Code Online (Sandbox Code Playgroud)
但是在那种情况下,我得到一个错误('c.call不是函数')任何想法?
这可能是一个非常简单的问题,在视图中,我将"点击"事件绑定到按钮,当点击该事件时,我希望重定向到一个全新的页面(例如,不是路线).
例如
events : {
"click .button" : 'redirect'
},
redirect : {
window.location('otherlink');
}
Run Code Online (Sandbox Code Playgroud)
我可以使用window.location,但似乎这是错误的方式?任何想法赞赏?
我正在使用辉煌的BlockUI,并使用默认设置
$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);
Run Code Online (Sandbox Code Playgroud)
这很棒 - 除非我在页面上添加自动完成元素,然后一旦用户开始输入就会启动blockUI.而不是显式设置ajax调用什么来启动块UI可以有人想到一种方法来禁用某些ajax函数的blockUI?
我有一个自动完成字段(改编自geo autocomplete以查找地理位置),当用户从列表中选择位置时,我会抓取lat/lon以及用于搜索的其他一些信息.但是现在它仅在用户实际从自动完成列表中选择时才起作用(而不是开始键入并单击输入,例如他们没有从列表中选择).
我正在http://www.airbnb.com/上看到我希望复制的行为,基本上如果你开始输入一个位置(例如伦敦),实际的文本字段预先填充了列表中的第一个条目 - 是否有人可以解释如何使用jquery自动完成功能完成此操作?我可以将autoFocus设置为true,专注于第一个字段,但实际上不填充文本字段?
任何帮助赞赏.
对于我最简单的用户和类别类,用户可以属于多个类别,定义如此
class Application_Model_User {
public function __construct() {
$this->userCategory = new ArrayCollection();
}
/**
* Unidirectional - Users have multiple categories they belong to
*
* @ManyToMany(targetEntity="Application_Model_Category")
* @JoinTable(name="user_category",
* joinColumns={@JoinColumn(name="user", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="category", referencedColumnName="id")}
* )
*/
}
private $userCategory;
public function getUserCategories() {
return $this->userCategory;
}
}
Run Code Online (Sandbox Code Playgroud)
为用户添加类别很容易,但我无法理解或从文档中看到我将如何删除特定关系...例如,如果我做了
$thing = $em->getRepository('Application_Model_User');
$result = $thing->findOneBy(array(
'id' => (int) 5
));
foreach($result->getUserCategories() as $category) {
if($category->getName() == 'Another Sub Cat') {
// Delete this relationship
}
}
$em->flush();
Run Code Online (Sandbox Code Playgroud)
我可以删除关系,如果我使用删除删除实体,整个类别被删除?
backbone.js ×2
jquery ×2
ajax ×1
autocomplete ×1
blockui ×1
doctrine-orm ×1
javascript ×1
redis ×1