text
stringlengths
46
37.3k
title
stringlengths
12
162
JS : I can not navigate to /users in my app , because it doesn ` t trigger fetching of all queries that I would expect it should . My app consists of an App component and some components that contain actual content like Dashboard or UserList . There is also an EnsureAuthenticationContainer but this is just a component ...
Relay : How to merge instead of override queries in nested routes ?
JS : MDN suggested that `` When the iterator 's next ( ) method is called , the generator function 's body is executed until the first yield expression '' and I do understand this example : However , I am confused when I come across another example : If the first next ( ) only execute code BEFORE the first yield , the ...
Does the first next ( ) in js generator function always execute until the first yield ?
JS : I want to set string properties on my array.E.g.The idea is to store some meta-data on the array itself.Is this a good approach ? Am I creating any problems by doing this ? <code> function readInput ( arr ) { var data = db.query ( 'something ' ) ; arr.itemType = data.itemType ; // - > This arr.push.apply ( arr , d...
What are the drawbacks of setting string properties on arrays ?
JS : Using jQuery when changing .html ( ) of an < option > inside a < select > ( Which I had previously set selectedIndex property to -1 ) resets selectedIndex property of < select > from '-1 ' to ' 0'http : //jsbin.com/filowe/2/edit ? html , output <code> < ! DOCTYPE html > < html > < head > < script src= '' //code.jq...
Changing .html ( ) of < option > resets selectedIndex property of < option > from '-1 ' to ' 0 '
JS : I came across this gist today , and in the comments the author mentioned thatis unnecessary , because in Javascript you can just use log to access the DOM element . Is this true across all browsers ? Is there a name/reference for this technique ? <code> var log = document.getElementById ( 'log ' ) ;
Is document.getElementById ( 'id ' ) or $ ( ' # id ' ) still necessary to select an element by ID ?
JS : I was trying to implement a functionality where a user can reset a password . I have tried the below code and while I am not getting any error , its not updating the password . The password is the same ie the old password.my User model file is as follows : -My routes file is as follows : -I am a bit confused where...
NodeJs : - Getting `` missing credentials '' error while using local passport
JS : I need to set a datetime-local picker 's default value to the current local time . Native JS seems to output in local time by default : However functions like toISOString ( ) output in UTC , and although I can pull out individual components locally , I do n't really want to fiddle around with padding and such . So...
Moment.js formats locally until I specify the format
JS : I looking for why closest ( ) find first itself element before traversing tree . For example : I would like fadeOut the parent div element when i click on children element , but the children element is too a div and so is the children who fadeOutWhy is itself element who fadeOut and no the parent div element ? I k...
Why closest ( ) find first itself element before travesing tree
JS : I am trying to populate the < mdt-column > inside of < mdt-header-row > dynamically with an array from controller . This piece of code does n't seem to work properly : hide-column-by-default= '' c.selector_hidden '' When loading the table default columns are not displayed . Some columns are set as default and are ...
Default Column are not displayed in Material Design Data Table ( iamisti/mdDataTable )
JS : I am still on my chart , and I need to default close the level 2 & 3 nodes , and keep the expand/collapse function on click.Depending on the node clicked and its level , run a specific action ( change color for example ) . My link must be a value of my data object ( var pubs in my codepen ) as you can see bellow (...
Add event listener per nodes level on d3 chart
JS : In JavaScript , it seems : Why is it not 4294958077 ? It suggests that there 's some sort of overflow kicking in ( although as I understand it a JavaScript Number type 's range is +/- 9007199254740992 so that 's odd in itself . ) Even if it was an overflow , surelyshould evaluate as true - but it doesn't.Help plea...
Why is JavaScript bitwise OR behaving strangely ?
JS : While experimenting with some different methods for generating JavaScript arrays , I stumbled on a weird result . Using map to push an array of self-references ( DEMO ) : I get the following result ( in Chrome ) : Can anyone explain why ? <code> a= [ 1,1,1,1,1,1,1,1,1,1 ] ; a=a.map ( a.push , a ) ; [ 13,16,19,22,2...
Array Self-Referencing Map - Very Bizarre Result
JS : I 'm looking for a better way to manage global component/plugin/widget initialization in a large project . It has many jQuery-powered components that I would like to initialize quickly & efficiently and after scouring the internet , I 've only really found short-sighted examples that are only realistic/performant ...
jQuery , A search for a smarter way to Initialize
JS : The table header is fixed , but it is at the top of the page after scrolling . It works exactly how I want it , except the thead is fixed in the wrong place.The table has an overflow-x : auto and the TD are using white-space : nowrap so the table expands to handle the content.I need it to be fixed 140 pixels from ...
Table Header Fixed beneath Fixed Page Header
JS : I 'm trying to solve this puzzle minded Javascript OOP problem.So I have the following class : When I call every method I expect to print the name of it , right ? But here is what i get : But when my class looks like this : Why is this happening ? <code> var ClassA = function ( ) { this.initialize ( ) ; } ClassA.p...
Javascript classes and variable references
JS : I want to let users enter the vehicle number and then read the data and show the vehicle details to the user . I do n't want to do it in a webview . I am able to fill the data using this code : Here is the website which shows the data for this app.https : //parivahan.gov.in/rcdlstatus/vahan/rcstatus.xhtmlNow I am ...
Fill website data and click button and parse response
JS : I have created a simple Hello world app using Angular 4 ( 4.3.0 ) . Angular files : — app.component.ts— app.component.html— app.module.ts TypeScript file Webpack fileHere is the full file but the important parts are : And DiagnosticsBefore optimization - When I run > webpack ( without webpack -- env.MODE=prod ) in...
Angular4 & Webpack - 300kb ( after optimization ) for a simple `` hello world '' app ?
JS : I 've been pouring over my code over and over again and I just ca n't see why it 's not working correctly ... Can someone enlighten me ? What 's the issue here ? I just do n't see it.The code should allow the user to enter various values into textboxes to change some of the image 's features such as border size , ...
Javascript image properties
JS : Just experimenting with different inheritance techniques in JS , and came across something mildly discomfiting about Crockford 's Prototypal Inheritance pattern : It 's all good - except when you log to console - the object appears as F. I 've seen classical emulation in which you can repoint the constructor - is ...
Minor drawback with Crockford Prototypical Inheritance
JS : I have two JSON objects defined in a controller ( NotificationsController ) . One with all the notifications and another one with only the ID of the newest notifications ( last 3 days ) .Format of object `` notifications '' : ( t_notifications ) Format of object `` newest notifications '' : ( newest_notifications ...
Searching through JSON Object with ng-class ( AngularJS )
JS : I have this function : How do I fix this with ES6+ destructuring ? I know I need something like ( on line 4 ) : const { basketItem : quantity } = quantity ; but I ca n't get line 3 working <code> const calculateTotal = ( items ) = > { return items.reduce ( ( totalPrice , basketItem ) = > { const price = basketItem...
Prefer destructuring es-lint error
JS : I was looking at some of the AJAX calls that GMail does , and I noticed that sometimes the return value of the calls started with a number . Example : ( note that there 's is no semi-colon after the first line ) If I were to enter this into a JavaScript console , I 'd get undefined returned back . However , if the...
Why does `` 3 [ 1 , 2 ] ; '' return undefined in JavaScript ?
JS : So I know what this does : Now I have seen people doing this lately : Are these two ways of doing the same thing ? I see an anonymous function being declared inside a jquery selector here , but never actually being invoked , yet by the way the page runs it seems that this may just run on pageload . <code> $ ( docu...
What is the difference between $ ( document ) .ready ( function ( ) and $ ( function ( ) ?
JS : Recently , I read the ECMAScript Language Specification . I did n't plan to read the whole specification , I just picked up some parts . I came cross many questions , one of them is like this : ToLengthAs I understand , it should be like this : I did n't understand what the meaning of ReturnIfAbrupt ( len ) is , a...
ECMA-262 ReturnIfAbrupt
JS : When using higher order function of the Array API in javascript ( forEach , map , filter , etc . ) there are 2 means to pass `` this '' variable : OrWhich one is the better ? What are the pros and cons ? Example : http : //jsfiddle.net/TkZgX/ <code> myArray.forEach ( function ( value ) { this.aContextualFunction (...
javascript higher order functions ; `` this '' parameters vs external `` self '' variable
JS : I was working with query params , and got introduced to URLSearchParams . I am using it to form this kind of object to query , Here , I dont want to have that c= , as it 's ugly , and my API does n't need that.So , I want this result a=hello+World & b=23 ( without empty query string ) But , I could n't find anythi...
How to remove empty query params using URLSearchParams ?
JS : I want to get the id of the first div ( it 's bar1 here ) when li is clicked . And there are more lis same as above . All those lis also have the CSS class `` intro-item '' When I click each of these , I want to get the id of first div.The idea is like this <code> < li class= '' intro-item '' > < a href= '' ... ''...
get the id of the first div within the clicked li
JS : We 've been using the Page Object pattern for quite a while . It definitely helps to organize the end-to-end tests and makes tests more readable and clean.As Using Page Objects to Organize Tests Protractor documentation page shows us , we are defining every page object as a function and use new to `` instantiate '...
Canonical way to define page objects in Protractor
JS : I just started using async/await and is confused on how it interacts with callback . For example , vs Must fooMethod be written in a specific way so that it can handle an async function as callback ? if fooMethod is a public library , how do I know that it is safe to add async keyword to the function ? FOLLOW UPEx...
Async function as callback
JS : I have the following script which fetches data ( branch names ) asynchronously via database : HTMLEverything is working perfectly , When user clicks link the data ( branch name ) gets added to the text input field , which is exactly what needs to happen , however ... My ProblemAfter user has clicked on desired lin...
Ajax / Javascript - Remove Links After 1 Link Has Been Clicked
JS : I 'm working with the Configure javascript defaults example from the monaco editor playground.https : //microsoft.github.io/monaco-editor/playground.html # extending-language-services-configure-javascript-defaultsWhen I start typing the pre-defined class , I get autocompletion , but I need to hit ctl+space one tim...
Always show the `` Show more '' section in monaco-editor
JS : My query is used in cases that `` ( function ( ) { ... } ) ( ) ; '' Given that I am not a plugin . For example `` http : //piecesofrakesh.blogspot.com/2009/03/downloading-javascript-files-in.html '' OrThank you . <code> ( function ( ) { var s = [ `` /javascripts/script1.js '' , `` /javascripts/script2.js '' ] ; va...
When should I use the syntax `` ( function ( ) { ... } ) ( ) ; '' ?
JS : It is well-known that declaring objects with JSON notation makes them `` inherit '' from ( or , more precisely , to be built like ) the base Object : myobj= { a:1 , b:2 } ; which is nearly equivalent to myobj = Object.create ( Object ) ; myobj.a=1 ; myobj.b=2 ; and than : Object.getPrototypeOf ( myobj ) prints the...
Why *not* `` inherit '' /extend from Object in JavaScript ?
JS : I am writing a few functions to simplify my interaction with Javascript Nodes , here is the source-code so far : Everything is working great and I am quite content with these functions , I have managed to prevent a lot of headaches without the usage of Javascript frameworks ( a hobby project ) .Now , I would like ...
How to concatenate two NodeList objects into one , avoiding duplicates
JS : I cam upon this code in an example for the EaselJS library - what it does is it assigns the namespace of the entire createjs library to `` window '' .My question is this : Is setting the namespace of a library to window a really dumb idea ? Does n't it just get rid of the whole point of using a namespace by making...
Set Javascript Namespace to Window : Bad idea ? Or Brilliant ?
JS : I am using Auth0 as my authentication provider for a SPA using React . I have followed the Auth0 react tutorial and this more detailed tutorial from their blog.I am currently just using just email/password authentication . And the authentication works as expected for login/logout , retrieving user info etc.However...
Auth0 does not persist login on page refresh for email/password
JS : I 've got a simple application with a simple css animation which works like a charm in AngularJS 1.2.2 + ngAnimate 1.2.2 : - > Runnable demo works like a charm.For ( maybe ) no reason the same codes does n't work with AngularJS 1.6.4 + ngAnimate 1.6.4 : - > Broken animation demoThe animation css classes were not a...
ngAnimate stopped working in AngularJS 1.6.4
JS : So I have an Angular view that has the following markup : The vm.handheldKeys when page is loaded is an array with two values [ 0,24 ] .When the page loads , the rendered HTML is the following ( tabbed for readability ) : This , of course , is what you 'd expect.Now , through some business logic , after the user h...
Angular ng-options gives empty select option on splice
JS : I maintain a greasemonkey script that monitors the current track playing as well as the progress on Soundcloud . Previously , I could just do require ( `` lib/audiomanager '' ) to get access to an object that would allow me to view the state of the entire page such as playing track info . The issue is , Soundcloud...
Accessing soundcloud 's lib/audiomanager via on-page JS
JS : Is the notion/concept of `` immediate events '' something that exists in Javascript implementations ? BackgroundIn this this answer to the question `` Is javascript guaranteed to be single-threaded ? '' the auther mentions something he refers to as immediate events . Such an immediate event is a callback function ...
Is there something as `` immediate events '' in Javascript ?
JS : I want to get the html including the selector that I am using to get the htmllet 's say I havewhen I do $ ( ' # foo ' ) .html ( ) I getIs there a way in jquery to get the whole html including the parent ( selector div ) I want this whole html <code> < div id= '' foo '' > < div id= '' bar '' > content < /div > < /d...
Get full html instead of just innner html
JS : I have built an app with SammyJs . It currently works perfectly in the browser . However , when I package it to Android using PhoneGap , the routes does not work anymore.I have found this SO question . However , the solution given does not work : Has anyone ever experienced the same issue ? EDITI am also using jqu...
Sammyjs routes not working with Phonegap
JS : I started learning react-redux-immutable couple of days ago and I am still quite confused about structuring my application . I have php ( symfony/laravel MVC background ) so it is not easy to get my head around some javascript concepts.1 ) I have lines WrapperComponent:2 ) That is connected to WrapperContainer3 ) ...
React Redux Responsibilities
JS : I have this code below that is a HTML page consisting of a tab i want to use my JavaScript multidimensional Array and get each first name and age to populate the < h3 > separately is there any simple way to accomplish this any suggestion would be greatly appreciated ! <code> function openCity ( evt , cityName ) { ...
Display javascript object in tab
JS : I wonder how the site jsfiddle.net is handling their textareas . When you resize one , the others shrink/gain size . I 've been trying to do it regularly with css but when I resize one , the other textarea pops under the first textarea . Something like this.so the other textarea goes down . The | are ment to be th...
I am wondering how js fiddle is handling their textareas concerning resizing and their layot
JS : I have an array of arrays below . With ES6 , how can I get a count of each value Good , Excellent & Wow into a new array e.g [ { name : Good , count : 4 } { name : Excellent , count : 5 } , { name : Wow , count:2 } ] in dynamic style . I am attempting to use Object.assign but I am failing to `` unique '' out the c...
Get count from Array of arrays
JS : This problem is so specific I am not sure any search would find a similar answer , so I am asking as though it is a new problem.The expected behavior : Click button 'mySol ' makes div My solution visibleClick button 'YASS ' makes div My solution hidden and div YASS solution visibleClick button 'Tak ' makes div YAS...
Function that tests if DIV is showing only works the second time
JS : I added bundleconfig.json to ASP.NET Core application . It has the following structure : Both scripts has been minified and merged into main.min.js . But after minification all async modifiers has been removed from result script . Function such as have been turned into : How do I avoid removing async modifier ? <c...
ASP.NET Core BundleMinifier removes async modifier after minification
JS : Following up on this thread : Lots of null values in an array mean any harm ? I did this with node.js : And I got So that leaves me with the question ( I could n't find it on Yahoogle ) how much memory is actually allocated for a null entry in an array in node . I do not plan to use 1000000000 entries , not even c...
how much memory does node allocate for null values in arrays
JS : Given Why is name identifier cast to string when using var at object destructuring assignment ? But not using let or const ? We can avoid this unexpected result by defining a different identifierthough curious as to the significance of var returning different results than let or const for the name identifier at a ...
When using object destructuring assignment , why is a property `` name '' cast to string ?
JS : I want to select the right-most , bottom-most cell in a < table > using jQuery.It 's not as easy as $ ( ' # tableId td ' ) .last ( ) , because a cell may span several rows . It should also handle < th > cells.Here 's my attempt so far : <code> function fixLastCell ( $ table ) { var $ lastCell = $ table.find ( 'td ...
How can I find the bottom-right-most cell in a table using jQuery ?
JS : http : //a2.twimg.com/a/1302724321/javascripts/widgets/widget.js ? 1302801865It is setup like this at a high level : public namespace : Then a closure : Within the application closure : Some methods are marked public , others private , and the only difference seems to be the naming convention ( private starts with...
Help understanding twitters widget.js file , a closure within a closure ?
JS : I have a simple rectangular anchor tag . I used jQuery to respond to click and touchstart events with the following : The HTML looks like this : The CSS is simple : I built this as a demo to show the problem I 'm talking about.When you tap the edge of the rectangular anchor , only the click event is fired . When y...
Why does Android click area have a wider radius than touchstart ? How can I make it consistent ?
JS : If I declare a variable in a function using var then a slot for that variable is added to the LexicalEnvironment defined by that function.In the above code the LexicalEnvironment associated with the function contains a slot with a key foo and a value of undefined.If I use a block-scoped declaration , how is the su...
How is block scope managed in the lexical environment ?
JS : I 'm new to d3js , but am familiar with javascript and the principles of data-visualisation.I 've tried to achieve an effects to visualize 2 dimensions of data using the aster plot diagram , but ca n't really get this thing to work like expected.Attached you 'll find the diagram I 'm trying to recreate and my exam...
d3js - Creating Asterplot-like Charts ( example included )
JS : for meta data on the page using attribute names like table : rowNum : < name > , eg , have been using colon-delimited names ( eg , name='emp:1 : emp_id ' ) for years with good success , but today got bit with colon delimited attribute namesin particular : are special character like ' : ' illegal in dom attribute n...
in javascript dom , are there rules to attribute names ?
JS : I understand that num1 being an object has a property .__proto__ via which it gets access to .toString ( ) by going down the prototype ( .__proto__ ) chain . In above case , num is a primitive type number . It means that it wo n't have any properties and methods . Then how 's it able to get access to .toString ( )...
How does primitive types in Javascript have methods and Properties ?
JS : I 'm new to javascript and could use your help . The first time my PJAX page loads , my tooltips work : They become stuck unless I do the following : I 've tried to reinitialize them on pjax : end or pjax : complete with no luck . I get a strange-looking tooltip if I hover a long time , but not a bootstrap tooltip...
Bootstrap 4 tooltips stop working after jquery-pjax AJAX call
JS : I want to rotate element onclick by adding CSS class to it . Problem is , when that same CSS class is removed , element is rotated for the second time.fiddle : https : //jsfiddle.net/L3x2zhd1/1/JS : CSS : How can I avoid this ? <code> var el = document.getElementById ( 'el ' ) ; el.onclick = function ( ) { el.clas...
How to avoid css transformation ( rotate ) when removing class ?
JS : How come this Javascript selectordocument.getElementsByClassName ( 'first-class class-child second-child ' ) looks identical to this jQuery selectoryet it does n't work the same way ? <code> $ ( '.first-class .class-chlid .second-child ' ) ;
Javascript class selection
JS : I have created a map using d3.js . I want to show a curved line between two locations . I am able to show a line , but sometimes it does not form a perfect curve . For some lines , the lines curve behind the map ( across the anti-meridian ) to their destination.Here 's a code pen demonstrating the problem : https ...
line on d3 map not forming a curve
JS : I have a hex code 1f610 , so the format string is \u { 1f610 } with in display . But how can I unescape it from the hex code ? I didwhat should I do to unescape it to ? <code> var code = '1f610 ' ; unescape ( ' % u ' + code ) ; //= > ὡ0unescape ( ' % u ' + ' { ' + code + ' } ' ) ; //= > % u { 1f610 }
javascript unescape hex to string
JS : I am using the angular-fullstack generator to generate new routes for my application . The syntax is really unfamiliar and uses a class-like structure . How do I work with this to inject things like $ scope and $ watch ? The main thing I want to do is watch for a change for a particular variable . The syntax is be...
How do I work with $ scope and $ watch with angular-fullstack generator syntax ?
JS : The Context : A hook is defined and returns an object that contains the timestamp of the last time a file was modified . I calculate the difference from the timestamp until now to show the user how long it was been since they have last saved . The Problem : The calculated difference from the timestamp until now do...
How can you trigger a rerender of a React js component every minute ?
JS : I have the following Javascript : Inside a .click ( ) function . This works fine . However I have the following HTML in the cloned area : Now , in the above jQuery I have this.checked=false ; which makes any cloned checkbox unchecked . But unfortunately , The label.button-array still has the class of active , whic...
Cloning a DIV with jQuery
JS : I have a pretty basic jQuery ajax thing happening , but I want to mix form data that is retrieved by JS with some PHP variables and have them all sent as part of the ajax GET . Should this work ? : Currently , when create.php tries to echo the variables back , they 're empty.UPDATEAfter checking the source as sugg...
mixing javascript and php variables in ajax
JS : Recently I have implemented a ebook like function web app runs on ipad . One function is to make a viewport to drag the book . I used this viewport plugin ( with demo ) : http : //borbit.github.com/jquery.viewport/The problem is the content can not drag .This work perfectly on desktop but not ipad.There are two le...
Implement Jquery viewport on ipad
JS : In my Yesod project i have the following route : I want to request it on the client side with javascript : But i ca n't use @ { ApiHideTHreadR } because Yesod requires it 's arguments on compile time . What is the proper solution for this , if i want API URLS to look like api/board/1/1 and not api/board ? bid=1 & ...
Yesod : Using typesafe URLs in AJAX calls
JS : I basically want to write the following code in ES6 fashion.I have tried using a property like the following but the _onNeonAnimationFinish callback is never fired.So what is the correct way ? <code> listeners : { 'neon-animation-finish ' : '_onNeonAnimationFinish ' } , class MyElement { get behaviors ( ) { return...
How to write listeners in ES6 in Polymer ?
JS : I 've been trying for the last few days to make my code work , but I just ca n't find the problem.I want to make communication with the Wikipedia server and get their JSON API so I can make a list of items corresponding to the input value of searchInput.I 've been looking into JSONP , finding in the end that I can...
Accessing Wikipedia API with JSONP
JS : I 've been working with the Grunt cssmin plugin . I had a block in my Gruntfile which looks approximately like this : For a while this was working fine ; but I moved this to another machine and did n't set up my bower components correctly - the html5-boilerplate/css/main.css file was missing - and yet the task sti...
Is there a way to cause a Grunt plugin to fail if input files are missing ?
JS : I have an application that has this format scattered around but I dont know what kind it is . It 's not jQuery , so what is it ? I get this in firebug and I know the element is present : <code> $ ( 'some_edit ' ) .style.display = `` block '' ; $ ( 'some_views ' ) .style.display = `` none '' ; $ ( `` some_edit '' )...
What kind of JavaScript is this ?
JS : I was working on canvas and came across the Idea of changing dimensions of the cube . So , by using HTML5 Canvas I made up this cube which has two squares joined by the lines to make it look like a cube.What I want is when I select a cube type from select the cube should automatically change itself depending on th...
Change dimension of canvas depending on selected option
JS : I want to achieve a way to get all the content between one open span tag and it 's close tag . The problem is that sometime I can have nested span and I want to be sure that my regex do n't stop a the first ending span it see.To see my problem look at this : Regex101 : nested spanI want to be sure that I get every...
Using XRegExp.matchRecursive for nested spans
JS : I made a slideshow with php and javascript and it slides the images just fine , but i 'm a bit stuck at the back and forward functionalities and i would be grateful if you could help me a bit here.This is what i 've done so far : PHP : Javascript : HTML : As you can see i tried to make an onclick event to change t...
Add back and forward functionalities in slideshow
JS : In a spelling game I have created there is a grid that is populated with words . The aim of the game is to spell the words by clicking on the letters on the side , which animate into the empty spaces in the grid . Words are highlighted if they are to be spelt , so the user can see where to go next . The aim of the...
jQuery/JavaScript program breaks after completion number is changed
JS : We all know javascript does funky conversions when testing for equality , but what exactly happens under the hood ? Yes , it was naive of me to expect transitivity from == operator . <code> > [ 0 ] == 0true > 0 == [ [ 0 ] ] true > [ 0 ] == [ [ 0 ] ] false
If both [ 0 ] == 0 and 0 == [ [ 0 ] ] are true than why is [ 0 ] == [ [ 0 ] ] false ?
JS : I have the following : Output isI 'd like it to output : How do I do this ? Thanks . <code> var tags = [ `` Favorite '' , `` Starred '' , `` High Rated '' ] ; for ( var tag in tags ) { console.log ( tag ) ; } 012 FavoriteStarredHigh Rated
How do I reference the string in a array of strings ?
JS : I 'm reading the book Javascript : The Good Parts . And I 'm confused by the following code.Where is the null in slice.apply ( arguments ) ? <code> Function.method ( 'curry ' , function ( ) { var slice = Array.prototype.slice , args = slice.apply ( arguments ) , that = this ; return function ( ) { return that.appl...
Why apply ( ) here takes only one argument instead of two ?
JS : Here 's my situation . I 've created several panels stacked side by side which are wrapped in a main container . Each panel takes 100 % the viewport width and height . My goal is to be able to scroll horizontally to each panel when I click on their respective link . This works fine using a pure css approach . Howe...
How do I obtain a floating element 's left offset while it is outside the viewport ?
JS : I want to be able to start my express server directly via : But I also want to able to require that file , and have it return the app instance but actually not start the server . Then I can start later it with some options.I 'm basically looking for the equivalent of this ruby snippet , but in node.js.Is there an ...
How do I make node.js execute some code only if my file is the running file ?
JS : I have been developing a chrome extension using Polymer for some time now and I have a couple of concerns about releasing it in it 's current state . I would like to hear about some strategies for preventing the following problems I have been facing : 1 ) Loading Polymer into the page leaks into the global namespa...
Problems loading Polymer 1.0 in a chrome extension
JS : Checking the HTML source of a question I see for instance : And then in the javascript source : It seems that all the user click events are binded this way.The downsides of this approach are obvious for people browsing the site with no javascript but , what are the advantages of adding events dynamically whith jav...
Why Stackoverflow binds user actions dynamically with javascript ?
JS : I 'm taking a course on AngularJS on Coursera . The code that the instructor demonstrated in the videos works but for some reason I could n't get to run on my environment : Page Layout ( partial ) : Snippet A ( demonstrated by professor that I could n't get to work ) : When I would run this function , I do n't get...
What 's the difference between these 2 Angular code snippets ?
JS : How to use switch for assignment in coffescript ? Tried many ways but could n't make it work.even this does n't worktried this way alsoAt last found this also does n't workAm I missing something ? <code> item = { name : `` ahola '' } arr = `` coffee_script '' switch arr when arr.match /script/ item.type = arr aler...
variable assignment with switch in coffescript
JS : I want to change the opacity of an object instead of fading in content that was completely hidden so I changedtoand the css from display : none to opacity : 0 ; ( in all browsers ) but I noticed that the numeral value 1000 isnt doing anything at all.. Maybe it is and I 'm not noticing , but I have changed that for...
Why are n't fadeIn and animate duration working for my code ?
JS : If I run this code within the Chrome Developer Tools : why is privateFunction1 in scope at the breakpoint , while privateFunction2 is not ? <code> var test = ( function ( ) { var publicFunction , privateFunction1 , privateFunction2 ; privateFunction1 = function privateFunction1 ( ) { return true ; } ; privateFunct...
Debugging Revealing Module Pattern : functions not in scope until called ?
JS : In Restangular if I declare a service , and do a PUT/PATCH/POST operation it uses the id of the item by default as a primary key . But what if we want to use a custom key ? Like a slug or a number ? <code> // GET to /usersUsers.getList ( ) .then ( function ( users ) { var user = users [ 0 ] ; // user === { id : 1 ...
Restangular - Specify custom ID key
JS : I am using Chromeless to retrieve a piece of information on a website and load a corresponding file : but the file read instructions are executed immediately when I launch the script and do not wait for the web crawling to be finished.In javascript I think I would need to use callback functions to prevent that but...
Chromeless - wait before executing instructions
JS : I 'm trying to render a partial with ajax , but for some reason it returns this error : I 'm very confused because I accomplished something with an essentially identical format before , and I never had any problems with it . Does anyone see anything wrong with my code ? I can render a string with the ajax ; it 's ...
j ( render ( @ partial ) ) returns error : ActionController : :UnknownFormat
JS : I 'm trying to implement a 'Tag Editor ' field in my app , the same way as SO does.Right now i got this : EDIT : I have coded this into a jQuery plugin at : https : //github.com/fernandotenorio/tagme.gitFiddlehttp : //jsfiddle.net/FernandoTen/PnYuF/htmljs } ) cssThe problem is , how can i handle the 'hidden ' cont...
Emulate SO tag editor
JS : I have a function that I 'm using to prevent multiple postbacks of a form : In the CanSubmit method , I need to interrogate the button that was clicked to determine whether I should allow the submit or not.Note that I ca n't bind to specific click events - see this previous question for more details.In Firefox , I...
How can I find the button that was clicked from the form submit event in jquery ?
JS : HtmlJavascriptOf course when I click anywhere in the div , it performs 'do magic ' . Thanks to return false , if I click on any link in the div , it still performs 'do magic ' and does n't change the page , which is the expected behavior.But there is one link that is suppose to actually change the page , the owner...
How to attach a onclick callback to a div but not on a link inside the div ?
JS : I have found this code snippet : In here : http : //www.dofactory.com/products/javascript-jquery-design-pattern-framework ( sorry , no id-s have been found on the page ) I do n't understand what these parts are doing : the `` 100 % '' in the second linethe var _true_ = true ; and var _false_ = false ; assignments ...
Strange javascript code
JS : This is a question for the guru of JavaScript . I 'm trying to do work with JavaScript prototype model more elegant . Here is my utility code ( it provides real chain of prototypes and correct work with instanceof operator ) : It allows me to do such thigns : My question is : Is there more simple way to do this ? ...
How do I do JavaScript Prototype Inheritance ( chain of prototypes )
JS : I do n't understand why fooA and fooB outcome different.does foo.prototyp = { } override the method defined in front of it ? Why fooA is state in front of prototype.x , it inherit the result , but not y and z ? <code> var foo = function ( ) { } fooA = new foo ( ) ; foo.prototype.x = 1 ; foo.prototype = { y : 2 , z...
Different between foo.prototyp.x = & foo.prototype = { x : }
JS : I am new to javascript.I am trying to make an simple toggle up div With user selection direction ill place the toggle div.After some googling I found one working fiddle But not as expected See the below screenshot to see the differenceWhen I select Some text on the front of the paragraph It works fine Like thisBut...
How to find a user selection weather forward or backward in javascript ?
JS : I 've written a fairly simple script that will take elements ( in this case , < p > elements are the main concern ) and type their contents out like a typewriter , one by one . The problem is that as it types , when it reaches the edge of the container mid-word , it reflows the text and jumps to the next line ( li...
Pre-formatting text to prevent reflowing
JS : I 'm extending Object like this : All works as expectedbut , whenthis keyword on the is_a ( ) function is same as foo right ? Why does it return different results ? <code> Object.prototype.is_a = function ( x ) { return this instanceof x ; } `` foo '' .is_a ( String ) // true '' foo '' .is_a ( Object ) // true '' ...
What is the difference between ` this instanceof String ` and ` `` foo '' instanceof String ` ?
JS : I am trying to fetch all events ( maximized , maximize etc ) . I have a suitable code for this from this link How to Detect Window On Minimize/Maximize Event in Chrome Extension ? .But the problem when switch tab ( using alt+tab ) window.chrome.onFocusChanged listener is not firing.My code : Is there a solution fo...
chrome.windows.onFocusChanged.addListener not firing on tab switching