This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// handle clicks to Update on detailpage | |
$j("#updateButton").click(function() { | |
// update local information in the inventory array | |
inventory[$j("#detailpage").attr("data-id")].Quantity__c = $j("#quantity").val(); | |
currentRecord = inventory[$j("#detailpage").attr("data-id")]; | |
// strip out ID before updating the database | |
var data = new Object(); | |
data.Quantity__c = currentRecord.Quantity__c; | |
// update the database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Detail page, to display details when user clicks specific Merchandise record --> | |
<div data-role="page" data-theme="b" id="detailpage"> | |
<!-- page header --> | |
<div data-role="header"> | |
<!-- button for going back to mainpage --> | |
<a href='#mainpage' id="backInventory" class='ui-btn-left' data-icon='home'> | |
Home | |
</a> | |
<!-- page title --> | |
<h1>Edit</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// handle successful retrieval of Merchandise records | |
function onSuccessSfdcMerchandise(response) { | |
// avoid jQuery conflicts | |
var $j = jQuery.noConflict(); | |
// debug info to console | |
SFHybridApp.logToConsole("onSuccessSfdcMerchandise: received " + response.totalSize + " merchandise records"); | |
// clear div_merchandise_list HTML | |
$j("#div_merchandise_list").html(""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Main page, to display list of Merchandise once app starts --> | |
<div data-role="page" data-theme="b" id="mainpage"> | |
<!-- page header --> | |
<div data-role="header"> | |
<!-- button for logging out --> | |
<a href='#' id="link_logout" data-role="button" data-icon='delete'> | |
Log Out | |
</a> | |
<!-- page title --> | |
<h2>List</h2> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// log message | |
SFHybridApp.logToConsole("Calling out for records"); | |
// register click event handlers -- see inline.js | |
regLinkClickHandlers(); | |
// retrieve Merchandise records, including the Id for links | |
forcetkClient.query("SELECT Id, Name, Price__c, Quantity__c FROM Merchandise__c", onSuccessSfdcMerchandise, onErrorSfdc); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// handle clicks to Collaborate on detailpage | |
$j("#chatterButton").click(function() { | |
// using the id of the current Merchandise record, get its Chatter feed items | |
SFHybridApp.logToConsole("Getting Chatter"); | |
forcetkClient.chatterFeed($j("#detailpage").attr("data-id"), updateChatterList, onErrorSfdc); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function refreshChatter(response) { | |
forcetkClient.chatterFeed($j("#detailpage").attr("data-id"), updateChatterList, onErrorSfdc); | |
} | |
function updateChatterList(response) { | |
// output debug information to the log | |
SFHybridApp.logToConsole("Got Chatter"); | |
SFHybridApp.logToConsole(response.items.length); | |
// clear div_chatter_list HTML |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add select Chatter functions to forcetk | |
// get feed-items | |
forcetk.Client.prototype.chatterFeed = function(id, callback, error) { | |
this.ajax('/' + this.apiVersion + '/chatter/feeds/record/' + id + '/feed-items', callback, error); | |
} | |
// post feed item | |
forcetk.Client.prototype.postChatterItem = function(id, text, callback, error) { | |
this.ajax('/' + this.apiVersion + '/chatter/feeds/record/' + id + '/feed-items', callback, error, "POST", '{ "body" : { "messageSegments" : [ { "type": "Text", "text" : "' + text + '" } ] } }'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Detail page, to display Chatter Information --> | |
<div data-role="page" data-theme="b" id="chatterpage"> | |
<!-- page header --> | |
<div data-role="header"> | |
<!-- button for going back to detailpage --> | |
<a href='#detailpage' id="backInventory" class='ui-btn-left' data-icon='arrow-l'> | |
Edit | |
</a> | |
<!-- page title --> | |
<h1>Collaborate</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add select Chatter functions to forcetk | |
// get feed-items | |
forcetk.Client.prototype.chatterFeed = function(id, callback, error) { | |
this.ajax('/' + this.apiVersion + '/chatter/feeds/record/' + id + '/feed-items', callback, error); | |
} | |
// post feed item | |
forcetk.Client.prototype.postChatterItem = function(id, text, callback, error) { | |
this.ajax('/' + this.apiVersion + '/chatter/feeds/record/' + id + '/feed-items', callback, error, "POST", '{ "body" : { "messageSegments" : [ { "type": "Text", "text" : "' + text + '" } ] } }'); | |
} |
NewerOlder