This page last changed on Jul 14, 2011 by rehan.iftikhar@involver.com.

sml.tag.RegistrationCode

Allows for programmatic assignment of codes via the RegistrationCode feature


Instance Methods

.requestCode(options)

Requests a code from the given RegistrationCode feature. This will pop-up a dialog unless the onCodeAssigned callback is overridden.

Options

name type description
feature_id number The feature ID of the RegistrationCode feature requesting the code from
callbacks object An object that maps 3 types of callbacks (onCodeAssigned, onNoCodesLeft, onError). See below.
Callbacks
key description
onCodeAssigned This callback is fired when the user calls requestCode() and is successfully assigned a code
onNoCodesLeft This callback is fired when the user calls requestCode() and there are no more registration codes left
onError This callback is fired when the user calls requestCode() and there was an error retrieving a code

Example

Renders the partial with local variables:
{% registration_code name:"bucket-default"%}
  <a href="#__" onclick="withNoCallbacks({{ registration_code.id }}); return false;">No callbacks (default behavior)</a>
{% endregistration_code %}
<br />
{% registration_code name:"bucket-assigned"%}
  <a href="#__" onclick="withCallbacks({{ registration_code.id }}); return false;">Code Assigned Callback</a>
{% endregistration_code %}

<script>
  function withNoCallbacks(feature_id) {
    new sml.tag.RegistrationCode().requestCode({feature_id: feature_id});
  }

  function withCallbacks(feature_id) {
    new sml.tag.RegistrationCode().requestCode({
      feature_id: feature_id,
      callbacks: {
        onCodeAssigned: function(data){ console.log("Here is data about your assigned code", data); },
        onNoCodesLeft: function(data){ console.log("There are no codes left!") }
      }
    });
  }
</script>

Related Topics

Document generated by Confluence on Feb 12, 2013 09:09