Posts

Showing posts from April, 2016

CRUD Operations on JSON object using AngularJs

AngularJS is a powerful JavaScript Framework. It is used in Single Page Application (SPA) projects. It extends HTML DOM with additional attributes and makes it more responsive to user actions. AngularJS is open source, completely free, and used by thousands of developers around the world. In this post we are going to see the code for how we can perform CRUD (Create, Read, Update, Delete) operations on JSON object. <!doctype html><html> <head> <title>CRUD OPERATIONS</title> <script src = "../js/angular.js"></script> <script> var myApp = angular.module("myapp", []); myApp.controller("tableController", function ($scope) { $scope.dataset = [{name: "shubham", email: "shubham@example.com"}, {name: "sagar", email: "sagar@example.com"} ]; $scope.newname = "test&quo

How to check if jQuery is already loaded in Magento

If you are building some custom extension for Magento and your extension includes jQuery, but you don’t want to load it if its already loaded by some other Magento extension or theme, then you can do so using your layout XML file as shown below. Here we are checking for the global window.jQuery variable. If that is undefined jQuery is not loaded yet. Add the following to your modules layout XML. <default> <reference name="head"> <block type="core/text" name="jquery_load"> <action method="setText"><text><![CDATA[if (!!!window.jQuery){ document.write('<script type="text/javascript" src="url/to/jquery/file.js"></script>');}]]></text></action> </block> </reference></default> This will be included in the head after all other javascripts are loaded and you can be sure jQuery wasn’t included if its already there.