function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BJamesBJames 

No more bind?

Referencing the text below... are there some pointers or better yet, tutorials on how to use dojo to mimic the bind method that was removed from the winter 07 release?

Thanks,
Bryan

>The bind function will no longer exist in the winter 07 >ajax toolkit. A better solution would be to create a >dojo or yahoo yui widget to properly encapsulate the >appropriate behavior.

>Dave
>Developer Program Manager
>BLOG - blog.sforce.com
DevAngelDevAngel
Don't have a Dojo sample but here is a simple bit of code to bind text fields to a query record.

Code:
<html>
<head>
    <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/8.0/connection.js"></script>
<script>

 var record;
 var lastNameInput;
 
 function addBinding(element, record, fieldName) {
  element.value = record[fieldName];  //Set the value in the form field
  element.bindingId = fieldName; //save the field name onf the form field
  if (!record.binding) {  //Check if the binding exists already
   record.binding = {} //Create an empty binding object
   record.binding.record = record; //store the record on the binding object
  }
  
  record.binding[fieldName] = {}; //Create an object on the binding specific to the data field
  record.binding[fieldName].element = element; //create a reference from data field to element
  if (!record.binding.set) { //Create a set function
   record.binding.set = function(field, value) {
    this.record[field] = value; //Update the field on the record
    if (this[field].element) { //Make sure we have a binding
     this[field].element.value = value; //Update the value in the form field
    }
    alert(record);  //Just to see the changes
   };
  }
  element.record = record;  // Associate the record with the form field
  element.onchange = bindingOnChange; //Set the onchange event for the form field
 }
 function bindingOnChange() {
  this.record[this.bindingId] = this.value;  //Update the record field
  alert(record); //Just to see the changes
 }
 
 function setup() {
  //Run a query
  var qr = sforce.connection.query("Select FirstName, Id, LastName From Contact Limit 1");
  //Get a single record
  record = qr.getArray("records")[0];
  //Create the bindings
  addBinding(document.getElementById("LastName"), record, "LastName");
  addBinding(document.getElementById("Name"), record, "FirstName");
 }
 
 function setNewLastName() {
  var newLN = document.getElementById("newLastName").value;
  record.binding.set("LastName", newLN);
 }
</script>
</head>

<body onload="setup();">

First: <input type="text" id="Name"></input>
Last: <input type="text" id="LastName"></input>
<br><br><BR>To change the last name using the record, enter here and click button.<BR>
<input type="text" id="newLastName"></input>
<input type="button" id="btnNewLastName" value="Set Value" onclick="javascript: setNewLastName()"></input>
</body>
</html>