Guest User

Untitled

a guest
Oct 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <apex:page controller="TestController" showHeader="false">
  2. <apex:includeScript value="{!URLFOR($Resource.HTML5Util, 'jquery.min.js')}" />
  3. <apex:includeScript value="{!$Resource.jQote2}"/>
  4.  
  5. <script>
  6. var contacts = new Array();
  7. j$ = jQuery.noConflict();
  8. j$(document).ready(function() {
  9. j$('#update').click(function() {
  10. j$('.lastNameInput').each(function(index) {
  11. for(var x = 0; x < contacts.length; x++) {
  12. console.log(j$(this).attr('id'));
  13. if(contacts[x].Id == j$(this).attr('id')) {
  14. if(contacts[x].LastName != j$(this).val()) {
  15. console.log("Updating "+contacts[x].LastName);
  16. contacts[x].LastName = j$(this).val();
  17. }
  18. }
  19. }
  20. });
  21. TestController.updateContacts(contacts,function(response,message) {
  22. if(response) {
  23. console.log('Updated');
  24. for (myKey in message){alert ("message["+myKey +"] = "+message[myKey]);}
  25. }
  26. });
  27. });
  28. });
  29.  
  30. function getMyContacts() {
  31. TestController.pullCurrentContacts(function(records,message) {
  32. contacts = records;
  33. j$('#contactList').jqoteapp('#contacts_tmpl', contacts);
  34. for (myKey in records[0]){
  35. console.log ("contacts[0]["+myKey +"] = "+contacts[0][myKey]);
  36. }
  37. });
  38. }
  39. </script>
  40. <button onclick="getMyContacts()">Click Me</button>
  41. <ul id="contactList">
  42. <script type="text/x-jqote-template" id="contacts_tmpl">
  43. <li>Contact: <input type="text" class="lastNameInput" id="<%=this.Id%>" value="<%= this.LastName %>">, <input type="text" value="<%= this.Account.Name %>"></li>
  44. </script>
  45. </ul><button id="update">Update</button>
  46. </apex:page>
Add Comment
Please, Sign In to add comment