草庐IT

call_me_virtual

全部标签

javascript - Angular 2 : setTimeout only called once

我正在Angular2中实现需要使用setTimeout的功能。我的代码:publicngAfterViewInit():void{this.authenticate_loop();}privateauthenticate_loop() {setTimeout(()=>{console.log("HellofromsetTimeout");},500)}setTimeout由ngAfterViewInit启动,但循环只执行一次,例如。“HellofromsetTimeout”只打印一次。问题:如何更改代码以使setTimeout起作用? 最佳答案

javascript - window.toString.call 在 IE8 中未定义

当你运行时:window.toString.call("")在FF/CH中一切正常,但在IE8中出现脚本错误。进一步调查发现,window.toString.call在IE8中未定义?你也可以运行这个:window.toStringinstanceofFunction;//falsealert(window.toString);//functiontoString(){//[nativecode]//}这是为什么以及如何解决它?我开始想知道jQuery最初是如何工作的? 最佳答案 window是一个宿主对象,ECMAScriptLa

javascript - AngularJs 指令 : call method from parent scope within template

我对Angular指令还很陌生,我很难让它做我想做的事。这是我所拥有的基础知识:Controller:controller('profileCtrl',function($scope){$scope.editing={'section1':false,'section2':false}$scope.updateProfile=function(){};$scope.cancelProfile=function(){};});指令:directive('editButton',function(){return{restrict:'E',templateUrl:'editbutton.t

javascript - handlebars.js 未捕获类型错误 : Object #<Object> has no method 'call'

有人帮忙解决handlebars.js的问题吗?我正在使用在Centos6.4上运行的handlesbars预编译模板。要安装这个,我安装了:npm:yum-y--enablerepo=epelinstallnpm首先继承以避免问题:npminstall-ginherits然后是Handlebars本身:npminstall-ghandlebars这给出了以下版本:handlebars@2.0.0-alpha.1/usr/lib/node_modules/handlebars乐观主义者@0.3.7(wordwrap@0.0.2)uglify-js@2.3.6(async@0.2.10,

javascript - rails : JS Controller Being Called Twice for Some Reason

出于某种原因,当我单击一个按钮时,我的Controller和生成的jquery函数被调用了两次。由于调用的js函数是toggle,这是一个问题,因为它会导致代码跳入和跳出View。这是表格:UnseenNotifications:"seen",:controller=>"notifications"},:remote=>true%>这是Controller:defseenrespond_todo|format|format.jsendend这里是jquery:$("div#notifications").toggle();$("div#count").html("'notificati

javascript - Backbone : Call an extended view's overridden render() function

我有一个WorkoutExerciseRowView,它扩展了ExerciseRowView。渲染函数非常相似,除了WorkoutExerciseRowView必须向ExerciseRowView的渲染添加一些参数。如何在WorkoutExerciseRowView的渲染函数中调用ExerciseRowView的渲染函数?varWorkoutExerciseRowView=ExerciseRowView.extend({render:function(){//returnthis.constructor.render({//doesn'tworkreturnthis.render({/

javascript - 上传中的 "Error calling method on NPObject!"

我正在使用Uploadify在我的CMS中上传文件。一切正常,直到最近。我得到一个错误在NPObject上调用方法时出错在这条线上document.getElementById(jQuery(this).attr('id')+'Uploader').startFileUpload(ID,checkComplete);关于这部分uploadifyUpload:function(ID,checkComplete){jQuery(this).each(function(){if(!checkComplete)checkComplete=false;document.getElementByI

javascript - Google reCaptcha 2 TypeError : a is null after calling grecaptcha. 重置

我有一个基于AJAX的注册页面,它可以在客户端和服务器上进行验证。当服务器端验证失败时,AJAX将错误返回到屏幕并尝试使用grecaptcha.reset()重置recaptcha。重置验证码似乎工作正常,客户可以重新勾选“我不是机器人”框并继续,但是在重置验证码后,页面上的滚动操作会导致大量类型错误:aisnulljavascriptrecaptcha_en.js错误。TypeError:aisnullhttps://www.gstatic.com/recaptcha/api2/r20151104115408/recaptcha__en.jsLine50代码(简化):varrecap

javascript - https ://graph. facebook.com/me/albums 有时什么都不返回

我一直在使用JavascriptSDK试验FacebookAPI。每当我登录Facebook时,我都可以非常可靠地调用:functioninit(){//CalledafterloadingtheFacebookSDKFB.api("/me",function(response){console.log(response.first_name);//"John"(alwaysworks)});}但我还想获取用户相册(当他们单击链接时),由于某种原因,此调用只能间歇性地工作:$(document).ready(function){$("#get-albums-link").click(f

javascript - this.someFunction.call(this, param); 的目的是什么?

我在很多地方都遇到过一些具有这种模式的代码:this.someFunction.call(this,param);但在我看来这只是一种更冗长的打字方式this.someFunction(param)该模式有时会出现在作为回调提供的函数中。如果相关的话,它恰好使用了Backbone。像这样:Backbone.View.extend({//otherstuff...someFunction:function(param){//...},anotherFunction:function(){this.collection.on("some_event",function(){this.som