background preloader

Javascript

Facebook Twitter

EJS - JavaScript Templates. Are you ever faced with a mess of HTML string concatenations like this?

EJS - JavaScript Templates

Var html = "<h1>"+data.title+"</h1>" html += "<ul>" for(var i=0; i<data.supplies.length; i++) { html += "<li><a href='supplies/"+data.supplies[i]+"'>" html += data.supplies[i]+"</a></li>" } html += "</ul>" If you're a web developer, the answer is probably yes. Beyond being ugly, the structure of your HTML is lost in the JavaScript. Adding to this layout would be difficult. How can we clean it up? In this tutorial, we'll show you how to improve the above code that produces a list of supply links.

EJS is a JavaScript templating library. This tutorial walks you through: Include EJS Before we put on the rubber gloves and get to the heavy scrubbing, lets get set up a bit. Your page needs to include EJS so your JavaScript can use it. Next add EJS to your HTML like this: Create a Template The first step towards cleaner code is separating your presentation markup (HTML) from your application logic (JavaScript). View Helpers. Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programm... A Freelance Web Designer's Survival Manual. Designing With Grid-Based Approach. Advertisement The main idea behind grid-based designs is a solid visual and structural balance of web-sites you can create with them.

Designing With Grid-Based Approach

Sophisticated layout structures offer more flexibility and enhance the visual experience of visitors. In fact, users can easier follow the consistency of the page, while developers can update the layout in a well thought-out, consistent way. However, it’s quite hard to find your way through all the theory behind grid systems: it isn’t easy at all. Some important notions and related key-facts can help to learn basics and keep essential techniques in mind. And this is what this article is all about. Examples of Grid-based design But first few examples of grid-based designs to make clear what the article is about. Things You Probably Don’t Know About Grid-based Design “The grid is the most vivid manifestation of the will to order in graphic design. [...] JSwiki. Required JavaScript Reading. I'm asked regularly about books and online resources to get up to speed on JavaScript.

Required JavaScript Reading

Seems like everyone wants to get in on the JS action and with good reason; it's a great language to know if you're interested in exciting career opportunities. It's also pretty fun to play with. With JavaScript's increased popularity, the number of books, blogs and tutorials about the language have grown exponentially and while I can't possibly know all of them, I've found some gems which I really like and would like to share those with you.

Books Note that I'm only listing books that I've read and can recommend. Professional JavaScript for Web Developers by Nicholas Zakas This continues to be my most recommended book. JavaScript’s Strict Mode and Why You Should Use It. Starting with ECMAScript 5, developers are able to place their code into a more constrained form of execution known as strict mode.

JavaScript’s Strict Mode and Why You Should Use It

Strict mode improves JavaScript code by enforcing better programming practices and eliminating some of the language’s insecure and ill-advised features. Strict mode is enabled by adding the following directive to your code: "use strict"; The “use strict”; directive can be used in two ways. The first method of invoking strict mode is at the file level. The second way to enable strict mode is at the function level. Javascript Snippet Tutorial - Dynamically Modifying Tables.

Whereas we've used Javascript to dynamically modify table contents in a previous tutorial, we've never written a tutorial specifically explaining how it's done.

Javascript Snippet Tutorial - Dynamically Modifying Tables

That's where this tutorial comes in. I'm going to demonstrate, through some simple examples, how to dynamically add and remove table rows and cells using Javascript. If you're wondering why someone would want to do this, the answer is simple: AJAX. If you make a request to the server for some tabular data, you're going to need some way of putting it on the screen. Fortunately, the creators of Javascript made the process straight forward and pretty intuitive. Html - Remove fragment in URL with JavaScript w/out causing page reload. Html - What is the difference between the different methods of putting JavaScript code in an <a>

JavaScript function in href vs. onclick. Html - what does link href="#" do. Frontend - How to edit a web interface (front end) Front-end editing in Rails. Best Ruby on Rails Front-end development strategy. Front end development workflow with angularjs and gruntjs. Front end development: where to start. Html - Fastest Method to Learn Web Design for a Developer.

Html - MVC Web Application - Best workflow for a front end developer. TDD/Testing CSS and HTML. JavaScript unit test tools for TDD. Href="javascript:" vs. href="javascript:void(0)" Hide - Fade in a div when hovered over another div in JavaScript. Dynamically Generated HTML, generated events vs static scripts. Html - Passing Parameters to Javascript. Onclick - clickable table row javascript. Setting attributes of html element inline. Onclick the second time round click. How to define an attribute in Angular's JQM library. Angularjs - inline directives with ng-bind-html-unsafe. Angularjs - In Angular app is using plain javascript objects good or bad practice. Ng-bind-html javascript AngularJS. AngularJS - passing an interpolated html fragment to a directive attribute. Angularjs - Angular JS Respond to Change made From Javascript. Is binding objects to angular's $rootScope in a service bad.

Styling using attribute selector on Angular's ng attributes. Angularjs - How to bind an Angular's controller function using javascript. AngularJS: Is ng-click "a good practice"? Why is there no ng-{event} in AngularJS. Angularjs - Angular's use of Inline JavaScript in HTML attributes is not "bad practice" Jquery - Is it bad practice to manipulate HTML content with JavaScript. Hook into an onClick event without using the HTML property.

Is it bad practice to embed JavaScript into the body of HTML. Why is it a bad practice to return generated HTML instead of JSON? Or is it. How to store arbitrary data for some HTML tags. What's the effect of adding 'return false' to an onclick event. Difference between obtrusive and unobtrusive javascript.

Html - What is the difference between the different methods of putting JavaScript code in an <a> Is there a more efficient way to toggle multiple classes on click than this. Syntax - What does "use strict" do in JavaScript, and what is the reasoning behind it. How to debug Javascript/jQuery event bindings with FireBug (or similar tool) JavaScript inline events syntax. What is the difference between call and apply. Correctness - When do I need to specify the JavaScript protocol.

What is the difference between onclick=a(); and javascript:onclick="a();" in inline javascript calls. Onclick="javascript:func()" vs. onclick="func()" Is it possible to click this button with .click() Click() a button named 'submit' in Javascript. Browser - Why is this line of code necessary in clicking a button with JavaScript. Browser - Why is this line of code necessary in clicking a button with JavaScript. Onclick - JavaScript on click redirect. Html - Triggering the enter in a textarea. How do I use the Enter key as an event handler (javascript)

Is there an "exists" function for jQuery. What's the equivalent of getElementsByTagName in jquery. Event.preventDefault() vs. return false. How can I get query string values. C# - ajax calender & autocompleteextender does not works when using modalpopup. Javascript closure inside loops - simple practical example. Please explain the use of JavaScript closures in loops. Language agnostic - What is a Lambda. Function - What is the difference between a 'closure' and a 'lambda' Scope - JavaScript closures vs. anonymous functions. How do JavaScript closures work.

Asp.net - How to make javascript work along with Ajax UpdatePanel. Insert Text at Cursor Position in Ajax HTML Editor, using client Script. Asp.net - Rebinding events in jQuery after Ajax update (updatepanel) Asp.net - Javascript event subscription after UpdatePanel async postback. C# - Display & refresh an UpdatePanel after a postback from a different UpdatePanel. Asp.net - Embedded javascript does not work after async postback from UpdatePanel. Asp.net - how to trigger updatepanel within a javascript function. Asp.net - Executing JavaScript after a GridView's paging callback. Asp.net - how to get javascript to execute in update panel.

.net - How do I get Javascript to run after an update panel has updated. C# - How to update controls[DataGrid,TextBoxes and Label] based on a row selection made in DataGrid that resideds in a updatePanel. Asp.net - jQuery ComboBox losing styling after postback. Asp.net - Async postback doesn't cause document.ready to be executed.

Asp.net ajax - How to have a javascript callback executed after an update panel postback. How do i trigger a callback function after an UpdatePanel's contents have completely loaded. Asp.net - Reload external javascript after asynchronous postback via UpdatePanel. Asp.net - call javascript after updatepanel postback. Asp.net - Prevent UpdatePanel loading entire page on server. How can I defer loading UpdatePanel content until after the page renders. Asp.net - How can I run some javascript after an update panel refreshes. Asp.net - How to call a client side javascript function after a specific UpdatePanel has been loaded. Asp.net - Is is possible to determine when an element has been rendered using JavaScript.

C# - Difference between RegisterStartupScript and RegisterClientScriptBlock. Asp.net - jQuery $(document).ready and UpdatePanels. Document Ready equivalent for ajax-loaded content via jQuery Mobile accordion. $(document).ready equivalent without jQuery. What's the equivalent of jquery's 'trigger' method without jquery.