developer

jQuery – multiple $(document).ready …?

Question: ❓❓❓ Question: If I link in two JavaScript files, both with $(document).ready functions, what happens? Does one overwrite the other? Or do both $(document).ready get called? For example, <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script type="text/javascript" src="http://.../jquery1.js"></script> <script type="text/javascript" src="http://.../jquery2.js"></script> jquery1.js : $(document).ready(function(){ $("#page-title").html("Document-ready was called!"); }); jquery2.js: $(document).ready(function(){ $("#page-subtitle").html("Document-ready was called!"); Read more…

By admin, ago
developer

Remove Object from Array using JavaScript

Question: ❓❓❓ How can I remove an object from an array? I wish to remove the object that includes name “Kristian” from “someArray”. For example: someArray = [{name:"Kristian", lines:"2,5,10"}, {name:"John", lines:"1,19,26,96"}]; I want to achieve: someArray = [{name:"John", lines:"1,19,26,96"}]; Good Answer: 👌👌👌 You can use several methods to remove an Read more…

By admin, ago
developer

How to handle anchor hash linking in AngularJS

Question: ❓❓❓ Do any of you know how to nicely handle anchor hash linking in AngularJS? I have the following markup for a simple FAQ-page <a href="#faq-1">Question 1</a> <a href="#faq-2">Question 2</a> <a href="#faq-3">Question 3</a> <h3 id="faq-1">Question 1</h3> <h3 id="faq-2">Question 2</h3> <h3 id="fa1-3">Question 3</h3> When clicking on any of the above Read more…

By admin, ago
developer

Can I find events bound on an element with jQuery?

Question: ❓❓❓ I bind two event handlers on this link: <a href='#' id='elm'>Show Alert</a> JavaScript: $(function() { $('#elm').click(_f); $('#elm').mouseover(_m); }); function _f(){alert('clicked');} function _m(){alert('mouse over');} Is there any way to get a list of all events bound on an element, in this case on element with id="elm"? Good Answer: 👌👌👌 Read more…

By admin, ago
developer

How to create separate AngularJS controller files?

Question: ❓❓❓ I have all of my AngularJS controllers in one file, controllers.js. This file is structured as follows: angular.module('myApp.controllers', []) .controller('Ctrl1', ['$scope', '$http', function($scope, $http) { }]) .controller('Ctrl2', ['$scope', '$http', function($scope, $http) } }]) What I’d like to do is put Ctrl1 and Ctrl2 into separate files. I would Read more…

By admin, ago
developer

Fatal error: Unable to find local grunt

Question: ❓❓❓ I removed the old grunt first,and I install the new grunt.But I got an error: D:\www\grunt-test\grunt grunt-cli: The grunt command line interface. (v0.1.4) Fatal error: Unable to find local grunt. If you’re seeing this message, either a Gruntfile wasn’t found or grunt hasn’t been installed locally to your Read more…

By admin, ago