草庐IT

get_collection

全部标签

javascript - 使用 Marionette.CompositeView 过滤 backbone.collection 的正确方法

我有一个Marionette.CompositeView需要渲染一个集合。我想在fetch和add操作上过滤这个集合。我尝试使用以下代码(1),但出现以下错误(2)。任何想法,谢谢。(1)varmyCompositeView=Marionette.CompositeView.extend({initialize:function(){this.collection=app.taskCollection.where({type:'todo'});}});(2)//UncaughtTypeError:Objecthasnomethod'on' 最佳答案

javascript - Angularjs 的 $http.get 在 IE11 中只执行一次

我正在学习angularjs,作为一个测试项目,我正在轮询一个服务器,该服务器返回一个事件进程列表(它们的pids)并显示这些。客户端代码如下所示:functionProcessCtrl($scope,$http,$interval){$scope.ReloadData=function(){varresult=$http.get("processdata",{timeout:1000});result.success(function(data,status,headers,config){$scope.processes=data;});}$scope.ReloadData();v

javascript - 在 http.get 之后从另一个 Controller 更新一个 Controller 中变量的值?

我有两个Controller。我想使用服务将变量从一个Controller更新到另一个Controller,但它没有更新。我希望Controller“select”中的变量$scope.names在Controller“current”中更新并显示它app.controller('select',['$scope','$http','myService',function($scope,$http,myService){$http.get('/myapp/stocknames').success(function(data){$scope.names=data;myService.na

javascript - 传单 : Map container is already initialized does not get solved by proposed answers

我正在尝试使用传单加载map。当我刷新map时,出现上述错误。我研究了这个问题的其他建议答案。但是,他们中没有一个对我有用。我正在尝试在由onclick事件运行的函数中加载map。这是代码:functionload_map_and_analyze_data(){varmymap=L.map('mapid',{center:newL.LatLng(the_center_splitted[0],the_center_splitted[1]),maxZoom:17,minZoom:11,zoom:14});//creatingthemap//therestofanalyzeandcodego

javascript - 相当于 Lodash _.get 和 _.has 的下划线

我正在尝试为Lodash_.get和_.has搜索等效的Underscore,它能够直接访问嵌套对象的存在和值值而不需要检查其parent的存在。但是,在我看来,下划线_.get和_.has只能检查第一级的值。varobject={'a':{'b':2}};_.has(object,'a.b');//lodashshowstrue_.has(object,'a.b');//underscoreshowsfalse 最佳答案 据我所知,undercore不执行深度搜索,因此您必须满足于浅层has和get(或更改为lodash).你也可

javascript - 使用 jQuery get() 加载大型文本文件的最佳实践

目前我将获取的结果存储在一个字符串中,因为我打开的文件是大小为3MB到20MB的纯文本文件。然后我解析这个字符串并修改它,以便最终结果可以以html格式输出。我只是想进行健全性检查,看看以这种方式加载是否是最好的方式?还有,有没有办法加载目标文本文件的一block,解析该block,请求另一个block等。有点像音乐播放器在播放歌曲时缓冲歌曲。谢谢 最佳答案 isthereawaytoloadachunkofthetargettextfile,parsethechunk,requestanotherchunk,etc.要检索资源的一

javascript - 使用 JQuery 提交 GET 表单时如何更改查询字符串?

假设我的页面中有一个像这样的简单表单:Minprice:Maxprice:当我提交表单时,我有以下网址:http://.../properties/search?min_price=100000&max_price=200000我想将此url更改为:http://.../properties/search?price=100000,200000为此,我使用了JQuery和JQueryquerystringplugin:$(document).ready(function(){$("#form_search").submit(function(){varquerystring=rewri

javascript - 如何欺骗 JavaScript GET 请求的用户代理?

如何欺骗JavaScriptGET请求的用户代理?setRequestHeader不允许使用User-Agent:xmlHttpRequest.setRequestHeader("User-Agent","..."); 最佳答案 简而言之:由于内置的​​跨域限制,您不能。一种“绕过”的方法是编写一个代理网络服务,让服务器欺骗您需要欺骗的任何header。 关于javascript-如何欺骗JavaScriptGET请求的用户代理?,我们在StackOverflow上找到一个类似的问题:

javascript - 为什么 Backbone Collection fetch 不返回 promise

以下示例代码运行良好:Auth_controller.prototype.isLogged=function(){//CheckiftheuserisauthenticatedvargetAuthStatus=this.auth_model.fetch();returngetAuthStatus;};Auth_controller.prototype.redirect=function(fragment,args,next){vargetAuthStatus=this.isLogged();varself=this;$.when(getAuthStatus).then(function

javascript - 使用 Sinon stub get 方法

我正在尝试对具有属性的对象的get方法进行stub,工作正常:sinon.stub(input.model,'get');input.model.get.returns(10);但是考虑一下我们是否需要在对象中stub一些特定的属性,例如:input.model.get('yourValue')↪这怎么能stub?有什么想法吗? 最佳答案 stub.withArgs()应该做你想做的。参见http://sinonjs.org/docs/#stubs.sinon.stub(input.model,'get').withArgs('yo