Don't think so... my script waits for dom ready, then calls MktoForms2.loadForm (which works) then calls onFormRender on the form object (as well as other functions on form as defined in the docs) - which comes back undefined.
However I noticed by logging out the objects "MktoForms2" and "form" that there is a method called MktoForms2.onFormRender() (as opposed to form.onFormRender() as stated in the documentation). Passing back & in a reference to form enables me to call it, as shown below:
[code]
(function($) {
$.fn.loadForm = function() {
var form = MktoForms2.loadForm("//app-sjg.marketo.com", "572-XMB-986", MarketoForm, function(form){
//this works
console.log(form); //shows no method called "onFormRender"
form.onSubmit(function(){
//this works
});
form.onValidate(function(){
//this works
});
// form.onFormRender(function(){
// //if uncommented this dies with the error decribed above
// });
return form;
});
return form;
}
$.fn.onFormRender = function(form) {
MktoForms2.onFormRender(function(form){
console.log("rendered");
form.getFormElem().find("*").removeAttr('style'); //strips all inline styles whenever the form is rendered
});
}
$(document).ready(function() {
var form = $().loadForm();
$().onFormRender(form);
});
}(jQuery));
[/code]
Does the API documentation & the examples need revising? Or am I missing something?
Thanks
Ben