Okay, this may seem somewhat esoteric, but I am trying to solve a particular issue with a directive I have written: https://github.com/michaelbromley/angularUtils/issues/37 Here is a simplified version of what is going on. This works: I have a directive that delegates to ng-repeat by dynamically adding an ng-repeat attribute to the element during the compile stage, and then compiles that el
好吧,这可能看起来有些深奥,但我正在尝试用我写的指令解决特定问题:https://github.com/michaelbromley/angularUtils/issues/37 这是一个正在发生的简化版本。 这工作: 我有一个指令,通过在编译阶段动态添加一个ng-repeat属性到元素来委托ng-repeat,然后编译该元素: myApp.directive('repeatDelegator', function($compile, $timeout) { return { compile: function(element, attrs){ attrs.$set('n
I'm trying to detect whether an element is visible after the DOM is ready. This element is a third party widget that loads slower than the page does. My console.log for 'dom ready' is firing - like it should, but my check to see if the element is visible is returning false, as the element loads after the dom is ready. Is there a way to listen for elements after the dom has loaded
我试图在DOM准备好之后检测元素是否可见。 这个元素是一个比页面加载速度慢的第三方小部件。 我的console.log for'dom ready'正在触发 - 就像它应该那样,但是我检查元素是否可见正在返回false,因为元素在dom准备好后加载。 在dom加载后有没有办法监听元素? <script> $(function(){ console.log('dom ready'); if($(element).is(':visible')){ console.log('element is v
I'm writing a lineChart directive which loads data from a given url : <line-chart dataurl="{{ some_url }}"></line-chart> Then in my lineChart directive, I have a controller which is supposed to load data : directive('lineChart', function() { return { restrict: 'EA', scope: { dataurl: '@' }, controller: function($scope,
我正在写一个从给定url加载数据的lineChart指令: <line-chart dataurl="{{ some_url }}"></line-chart> 然后在我的lineChart指令中,我有一个应该加载数据的控制器: directive('lineChart', function() { return { restrict: 'EA', scope: { dataurl: '@' }, controller: function($scope, $http){ $http.get($scope.dataurl)
I'm trying to implement a $q.all to run some functions and then return all the outputs into a function attached to the .then at the end. At the moment the promises look like they're calling in the correct order and the $all .then is occurring at the end, but the results variable comes back with an array of nulls (one for each promise in the $q.all) JS Fiddle can be found at http://jsf
我试图执行一个$ q.all来运行一些函数,然后将所有输出返回到最后附加到.then的函数中。 目前承诺看起来像是按照正确的顺序调用,并且$ all .then发生在最后,但结果变量带有一组空值(在$ q.all中的每个promise都有一个) JS小提琴可以在http://jsfiddle.net/QqKuk/120/找到,我正在使用角1.0.1 以下是我拥有的代码的简单示例。 这里是我的html,只是在那里显示一些调试文本和输出。 <div ng-controller="MyCtrl">
The Situation Lets say I have a directive, that has to access certain elements via ID, inside the element on which the directive is defined. The problem, that can occur, is that by the time the directive is evaluated, the child-elements are not yet. The result is, that I'm not able to access those elements by their ID. Example FIDDLE <div ng-controller="MyCtrl"> <div color
情况 比方说,我有一个指令,它必须通过ID访问某些元素,在定义指令的元素内部。 可能发生的问题是,在指令被评估时,子元素还没有。 结果是,我无法通过他们的ID访问这些元素。 例 小提琴 <div ng-controller="MyCtrl"> <div color="elementId"> <div ng-repeat="item in items" id="{{ item.id }}"> {{ item.name }} </div> </div> </div> <script
I would like to create a custom HTML table/list with a lot of rows. I need row virtualization, but I'm not sure what's the best way to achieve this. By row virtualization I'm referring to the concept where the rows of the table/ul/div are not visible or rendered at all as long as they are not scrolled into the view. Basically, the point is to eliminate rendering if the item is nev
我想创建一个包含很多行的自定义HTML表格/列表。 我需要行虚拟化,但我不确定实现这一目标的最佳方式。 通过行虚拟化,我指的是只要不滚动到视图中,表/ ul / div的行根本不可见或不可见的概念。 基本上,重点在于如果该项目从不显示(滚动后面),则不需要渲染。 有任何想法吗? 我认为只要“滚动查看”,DOM元素就需要添加到列表中。 然后,我需要有一个无形的div与所有行的总高度的高度,使滚动成为可能。 有没有简单
I would like a RegExp that will remove all special characters from a string. I am trying something like this but it doesn't work in IE7, though it works in Firefox. var specialChars = "!@#$^&%*()+=-[]/{}|:<>?,."; for (var i = 0; i < specialChars.length; i++) { stringToReplace = stringToReplace.replace(new RegExp("\" + specialChars[i], "gi"), ""); } A detailed description of
我想要一个RegExp,它将删除字符串中的所有特殊字符。 我正在尝试这样的东西,但它在IE7中不起作用,尽管它在Firefox中起作用。 var specialChars = "!@#$^&%*()+=-[]/{}|:<>?,."; for (var i = 0; i < specialChars.length; i++) { stringToReplace = stringToReplace.replace(new RegExp("\" + specialChars[i], "gi"), ""); } RegExp的详细描述也会有帮助。 var desired = stringToReplace.replace(/[^ws]
I added link to context menu of img in ckeditor, using this code CKEditor - Add Context Menu Item to Images How can I get the information about the image, on which user clicked? For example the id of the image. Or the path. In order to process with the selected image. The solution was pretty easy. $('body').on('contextmenu','img',function(){ var imgid = $(this).attr('id'); alert(imgid); }
我添加链接到ckeditor的img上下文菜单,使用此代码CKEditor - 将上下文菜单项添加到图像 如何获取有关图像的信息,用户点击哪些信息? 例如图像的ID。 或者路径。 为了处理所选图像。 解决方案非常简单。 $('body').on('contextmenu','img',function(){ var imgid = $(this).attr('id'); alert(imgid); }) 使用jQuery来跟踪点击图片,我们可以将它的id保存到全局变量中。 然后,在插件的命令中,获取我们之前保存的ID
I'm using modal windows from Foundation and I have an alert every 3 seconds when it's opened. The point is I want to disable the interval when modal window is closed. I tried the following but clearInterval function doesn't seem to work (alert is still genarated after modal is closed): $(document).on('opened', '[data-reveal]', function () { var interval = setInterval(fu
我使用基金会的模式窗口,每打开一次,我都会有一个警告。 重点是我想关闭模式窗口关闭时的时间间隔。 我尝试了以下方法,但clearInterval函数似乎不起作用(模式关闭后警告仍然发生): $(document).on('opened', '[data-reveal]', function () { var interval = setInterval(function(){alert("O.K.");}, 3000); if($("div#automate_message").height() > 100) { interval; } }); $(document
I might just be being dense here... I have a variable timeDiscount that is true when page loads. Also when page loads, counter begins. At end of counter, I set timeDiscount to false ... except that this doesn't seem to work... In this jsFiddle, clicking the "CLICK" word will alert you to the current state of timeDiscount , the click returns true even after the counter has stoppe
我可能只是在这里密集...我有一个可变的timeDiscount页面加载时是true 。 当页面加载时,计数器开始。 在柜台结束时,我将timeDiscount设置为false ...除了这似乎不起作用... 在这个jsFiddle中,单击“单击”字将提醒您当前的timeDiscount状态,即使计数器已停止,点击仍返回true。 这是为什么? https://jsfiddle.net/df773p9m/4/ function startTimer(duration, display) { var timer = duration, minutes, seconds;