Skip to content

Instantly share code, notes, and snippets.

View kiran-machhewar's full-sized avatar

Kiran Machhewar kiran-machhewar

View GitHub Profile
<aura:event type="APPLICATION" description="Event template" >
<aura:attribute name="data" type="Object"/>
</aura:event>
<aura:event type="APPLICATION" description="Event template" >
<aura:attribute name="data" type="Object"/>
</aura:event>
<aura:event type="APPLICATION" description="Event template" >
<aura:attribute name="data" type="Object"/>
</aura:event>
({
initialize : function(component, event, helper) {
var action = component.get("c.getContacts");
var self = this;
action.setCallback(this, function(a) {
var contacts = a.getReturnValue();
component.set("v.contacts", contacts);
console.log('Contacts are loaded.');
});
$A.enqueueAction(action);
public with sharing class LightningOutExampleController {
@AuraEnabled
public static List<Contact> getContacts(){
return [SELECT Id, Name From Contact ];
}
}
<aura:component controller="LightningOutExampleController">
<aura:attribute name="contacts" type="Contact[]" default="[]"></aura:attribute>
<aura:handler name="init" value="{!this}" action="{!c.initialize}" />
<aura:handler event="c:lightningAppEvent" action="{!c.lightningAppEventHandler}"/>
<aura:registerEvent name="lightningAppExternalEvent" type="c:lightningAppExternalEvent" />
<aura:iteration items="{!v.contacts}" var="contact">
@kiran-machhewar
kiran-machhewar / Loading.component
Created December 31, 2013 04:30
Showing busy icon.
<apex:component >
<style>
body.wait, body.wait *{
cursor: wait !important;
}
</style>
<script>
//overriding the default send function of XMLHttpRequest
function addXMLRequestCallback() {
<apex:page standardController="<Your custom/standard object api name>">
<apex:detail subject="{!<Your custom/standard object api name>.Id}" relatedList="true" title="true"/>
</apex:page>
<apex:page >
<script>
if(confirm('Do you want to reload parent window by closing this child window?')){
top.window.opener.reloadPage('/home/home.jsp');
top.window.close();
}
</script>
</apex:page>
<apex:page sidebar="false" showHeader="false">
<script>
window.open('/apex/ChildPage','name','height=450,width=1000,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
function reloadPage(url){
window.location=url;
}
</script>
</apex:page>