I have set up a key and can get the recaptcha to show on the page it self but I don't know how to get it into a form.
Actually I don't want to use an id since I'll be reusing this later inside the app too so to use itemId would be preferred.I'm assuming that the element hasn't been created yet.
My include: HTML Code:
<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
Error (generated from recaptcha_ajax.js. Can't get the control with id 'recaptcha'): Uncaught TypeError: Cannot set property 'innerHTML' of null
Here's the code:
Ext.define('Login.view.Login', {
extend: 'Ext.form.Panel',
alias: 'widget.Login.view.Login',
border: false,
bodyPadding: 5,
initComponent: function() {
var config = {
layout: 'anchor',
defaultType: 'textfield',
defaults: {
anchor: '100%',
allowBlank: false
},
items: [{
fieldLabel: 'Company Id',
name: 'companyId'
},{
fieldLabel: 'Username',
name: 'username'
},{
fieldLabel: 'Password',
name: 'password',
inputType: 'password'
},{
/*xtype: 'panel',
itemId: 'reCaptcha',
border: false,*/
html: '<div id="recaptcha">adsf</div>'
}],
buttons: [{
text: 'Login'
}]
};
Ext.apply(this, config);
this.callParent();
},
afterRender: function() {
Recaptcha.create("heres_my_public_key",
document.getElementById('recaptcha'),
{
theme: "clean"/*,
callback: Recaptcha.focus_response_field*/
}
);
this.callParent();
}
});
Anyone done this using ExtJS 4?
/K
captcha created too early. Solution:
//after creating reCaptcha div call the following lines.
< div id="reCaptcha" > < / div>
if ($("#reCaptcha").length>0)
function showRecaptcha(element) {
}