Knockout disable select option caption

With knockout 2.3.0 the optionsAfterRender binding has been introduced so that the options can be changed quite flexibly. I'd like to disable the options caption. At the moment I'm doing <select data-bind="options: items, optionsCaption:'please select', optionsAfterRender: function(option, item) { ko.applyBindingsToNode(option, {disable: !item}, item); }"></select> which

禁用停用选择选项标题

在淘汰赛2.3.0版本中,引入了optionsAfterRender绑定,以便可以灵活地更改选项。 我想停用选项标题。 目前我正在做 <select data-bind="options: items, optionsCaption:'please select', optionsAfterRender: function(option, item) { ko.applyBindingsToNode(option, {disable: !item}, item); }"></select> 哪些工作,但我必须复制并粘贴optionsAfterRender函数无处不在。 我一直在试图创建一个自定义绑定

Count divs in outside window height position

do you know if there is a way in jquery/javascript to count the divs outside window screen height? like the image, in the green area ? Thank you in advance 我已经创建了示例片段作为参考如何检查Mojo在评论中是否提供了屏幕外的元素jQuery.expr.filters.offscreen = function(el) { var rect = el.getBoundingClientRect(); return ( (rect.x + rect.width) < 0 || (rect.y

在外窗高度位置计数div

你知道是否有一种方法在jquery / JavaScript中计数窗口屏幕高度之外的div? 像图片一样, 在绿色区域 ? 先谢谢你 我已经创建了示例片段作为参考如何检查Mojo在评论中是否提供了屏幕外的元素jQuery.expr.filters.offscreen = function(el) { var rect = el.getBoundingClientRect(); return ( (rect.x + rect.width) < 0 || (rect.y + rect.height) < 0 || (rect.x &

How to check if div is visible to user or not?

Basically i have a notification in the slide bar which is by default not visible(toggled).When any notification comes , it gets populated in the slidebar and on click of a toggle button slide bar opens from right to left.How can i make sure whether user has viewed a particular notification in slideBar. something similar to this link i have done. On click of the toggle on top right the slide b

如何检查div是否对用户可见?

基本上我在滑动条上有一个默认不可见的通知(切换)。当有任何通知时,它会在滑动条中填充,然后单击一个切换按钮滑块从右向左打开。如何确定用户是否在slideBar中查看了特定的通知。 类似于我已经完成的这个链接。 点击右上角的切换按钮,滑动条会打开,通知将会显示。如何知道该状态? 如果你使用jQuery,你可以做类似的事情if($(element).is(':visible')) { // Hello }

How do I find out which DOM element has the focus?

I would like to find out, in Javascript, which element currently has focus. I've been looking through the DOM and haven't found what I need, yet. Is there a way to do this, and how? The reason I was looking for this: I'm trying to make keys like the arrows and enter navigate through a table of input elements. Tab works now, but enter and arrows do not by default it seems. I

如何找出哪个DOM元素具有焦点?

我想在Javascript中找出哪些元素当前有重点。 我一直在浏览DOM,但还没有找到我需要的东西。 有没有办法做到这一点,以及如何? 我一直在寻找的原因是: 我试图使像箭头键和enter通过输入元素表中导航。 Tab现在可以工作,但输入和箭头似乎并不默认。 我已经设置了关键处理部分,但现在我需要弄清楚如何在事件处理功能中移动焦点。 使用document.activeElement ,它在所有主流浏览器中都受支持。 以前,如果您试图找

How do I check if an element is really visible with JavaScript?

This question already has an answer here: Check if element is visible in DOM 16 answers For the point 2. I see that no one has suggested to use document.elementFromPoint(x,y) , to me it is the fastest way to test if an element is nested or hidden by another. You can pass the offsets of the targetted element to the function. Here's PPK test page on elementFromPoint. I don't know

如何使用JavaScript检查元素是否真的可见?

这个问题在这里已经有了答案: 检查元素在DOM 16答案中是否可见 对于第2点。 我发现没有人建议使用document.elementFromPoint(x,y) ,对我来说这是测试一个元素是否被另一个元素嵌套或隐藏的最快方法。 您可以将目标元素的偏移量传递给函数。 这里是elementFromPoint上的PPK测试页面。 我不知道这些在较老的或不太现代的浏览器中支持多少,但是我正在使用类似的东西(没有任何库的需求): function visible(element)

Getting the ID of the element that fired an event

Is there any way to get the ID of the element that fires an event? I'm thinking something like: <html> <head> <script type="text/javascript" src="starterkit/jquery.js"></script> <script type="text/javascript"> $(document).ready(function () { $("a").click(function () { var test = caller.id; alert(test.val());

获取触发事件的元素的ID

有什么方法可以获取触发事件的元素的ID吗? 我在想这样的事情: <html> <head> <script type="text/javascript" src="starterkit/jquery.js"></script> <script type="text/javascript"> $(document).ready(function () { $("a").click(function () { var test = caller.id; alert(test.val()); }); }); </script> <

1.10.2.min.map is triggering a 404 (Not Found)

I'm seeing error messages about a file, min.map , being not found: GET jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found) Screenshot Where is this coming from? If Chrome DevTools is reporting a 404 for a .map file (maybe jquery-1.10.2.min.map , jquery.min.map or jquery-2.0.3.min.map , but can happen with anything) first thing to know is this is only requested when usin

1.10.2.min.map触发404(Not Found)

我看到有关文件min.map错误消息,找不到: GET jQuery的jquery-1.10.2.min.map正在触发一个404(Not Found) 截图 这是从哪里来的? 如果Chrome DevTools报告.map文件(可能是jquery-1.10.2.min.map , jquery.min.map或jquery-2.0.3.min.map ,但可以随任何事情发生),则首先要知道404这是仅在使用DevTools时才需要的。 你的用户不会打这个404。 现在您可以修复此问题或禁用源映射功能。 修复:获取文件 接下来

How to debug JavaScript/jQuery event bindings with Firebug (or similar tool)

I need to debug a web application that uses jQuery to do some fairly complex and messy DOM manipulation. At one point, some of the events that were bound to particular elements, are not fired and simply stop working. If I had a capability to edit the application source, I would drill down and add a bunch of Firebug console.log() statements and comment/uncomment pieces of code to try to pinpoin

如何使用Firebug(或类似工具)调试JavaScript / jQuery事件绑定

我需要调试一个使用jQuery来执行一些相当复杂和混乱的DOM操作的Web应用程序。 有一段时间,某些与特定元素相关的事件不会被解雇,而只是停止工作。 如果我有能力编辑应用程序源代码,那么我会深入研究并添加一堆Firebug console.log()语句和注释/取消注释代码片段,以试图找出问题所在。 但是让我们假设我无法编辑应用程序代码,并需要使用Firebug或类似工具在Firefox中完全工作。 Firebug非常擅长让我导航和操作DOM。 但

JS: event listener for when element becomes visible?

I am building a toolbar that is going to be included into a page. the div it is going to be included in will default to display:none . Is there a way i can put an event listener on my toolbar to listen for when it becomes visible so it can initialize? or will I have to pass it a variable from the containing page? Thanks javascript事件处理用户交互,如果你的代码组织得不够,你应该能够在可见性

JS:什么时候元素变得可见的事件监听器?

我正在构建一个要包含在页面中的工具栏。 它将被包括在内的div将默认显示:无 。 有没有办法让我的工具栏上放置一个事件监听器来监听它是否可见,以便它可以初始化? 或者我将不得不从包含页面传递一个变量? 谢谢 javascript事件处理用户交互,如果你的代码组织得不够,你应该能够在可见性改变的地方调用初始化函数(即你不应该在很多地方改变myElement.style.display,而是调用一个功能/方法,做这个和你可能想要的任何

The preferred way of creating a new element with jQuery

I've got 2 ways I can create a <div> using jQuery . Either: var div = $("<div></div>"); $("#box").append(div); Or: $("#box").append("<div></div>"); What are the drawbacks of using second way other than re-usability? The first option gives you more flexibilty: var $div = $("<div>", {id: "foo", "class": "a"}); $div.click(function(){ /* ... */ }); $("

用jQuery创建新元素的首选方法

我有2种方法可以使用jQuery创建<div> 。 或者: var div = $("<div></div>"); $("#box").append(div); 要么: $("#box").append("<div></div>"); 使用除可重用性之外的第二种方法有什么缺点? 第一个选项给你更多的灵活性: var $div = $("<div>", {id: "foo", "class": "a"}); $div.click(function(){ /* ... */ }); $("#box").append($div); 当然, .html('*')会覆盖内