I have three drop down lists, one list is populated on page load and doesn’t change. The 2nd and 3rd lists may change depending on the selection. This functionality is working fine. I have tried to add Bootstrap selectpicker to the selectors and I can see it is working – unfortunately the lists ar…
Author: admin@master
Uncaught TypeError: Cannot read property ‘substr’ of undefined
Pardon me for not being clear, but have thia script that is really long. When I have it live, I get this error in Chrome’s Console. Uncaught TypeError: Cannot read property ‘substr’ of undefined here is the snippet of code where it is reading from. I looked up substr on google and it appears…
jQuery unbind after first click
This causes multiple buttons to take action: When fileThisEmail runs, I’d like to remove it from ONLY the current one (there are others on the page that still need it): I tried off, but couldn’t seem to get it right. Any ideas? Answer In this case, you have to make the current element no longer ma…
Convert number of days into years, months, days
I have two date pickers that calculates the number of days there are between the two dates. At the moment I’m outputting the number of days (see code below) which is kind of meaningless. I want to output that number in years, months, days. How can I do that? E.g So 01/01/14 to 01/02/15 = 397 days which …
Mongoose find/update subdocument
I have the following schemas for the document Folder: So, for each Page I can have many permissions. In my CMS there’s a panel where I list all the folders and their permissions. The admin can edit a single permission and save it. I could easily save the whole Folder document with its permissions array,…
Trim specific character from a string
What’s the JavaScript equivalent to this C# Method: C# trims the selected character only at the beginning and end of the string! Answer One line is enough: A general solution: Parameter c is expected to be a character (a string of length 1). As mentionned in the comments, it might be useful to support m…
Fire event only when clicking on an element, and not on its children
If I bind a click handler to the body element, when I click anything on the page the event is triggered. I can check the event.target on every click: but that seem a bit overkill. Is there a way to trigger the event only when clicking the blank area of the body itself? Answer You can use the eventPhase proper…
addEventListener firing multiple times for the same handle when passing in arguments with anonymous function
For some reason, the event listener is firing twice for each element when passing arguments into an anonymous function. I.e., the click event on element el will register once and, thus, fire once. But if I want to pass my own arguments to it, it will register and fire twice. The question is why and what’…
Add class to element when scrolled into view (scrollable div)
Is there a solution for adding a class to the element in view when scrolling, and removing when out of view? This needs to work for a scrollable div. I have found a few solutions so far but they only seem to work for body… not a scrollable div. I am happy to use a plugin if you know one
JavaScript CSS styling in IE
JavaScript CSS styling not working in IE, it is working in Chrome and Mozilla. This is my code: This is my HTML And this is my CSS Please Help. Answer Try this