PDA

View Full Version : Append a List View in a controller on click of a form button



vikramiyer
9 Aug 2012, 6:26 AM
Here is my view code



Ext.define('Namespace.view.Activity', {
extend: 'Ext.form.Panel',
xtype: 'activity',
id: 'activityForm',

config: {
title: 'Activity',
iconCls: 'home',

styleHtmlContent: 'true',
items:[{
xtype: 'fieldset',
title: 'Updates',

items:[{
xtype: 'textareafield',
maxRows: 4,
name: 'post'
}]
},{
xtype: 'button',
text: 'Post',
ui:'confirm',
id: 'post_btn',
width: '100px',
action: 'submitPost'
}]
}
});

and my controller code

Ext.define("Namespace.controller.Home", {
extend: 'Ext.app.Controller',
views : ['Home','Activity'],

config: {
refs: {
postButton: 'tabbar button[title=Activity]',
activityForm: '#activityForm'
}
},


init: function() {

this.control({
'button[action=submitPost]': {
tap: 'submitActivityForm'
},
'tabbar button[title=Activity]': {
tap: 'clearBadgeText'
}
});
},


submitActivityForm: function() {

var form = this.getActivityForm();

console.log(form);

/* form.submit({
url: 'contact.php',
method: 'POST',
success: function(){
alert("Form submitted successfully"+JSON.stringify(form.getValues(), null, 2));
}
});*/

var badgeText = this.getPostButton(),
badgeNumber = parseInt(badgeText.getBadgeText()),
nextnumber = isNaN(badgeNumber) ? 1 : badgeNumber+1;

badgeText.setBadgeText(nextnumber);

},

clearBadgeText : function() {

var badgeText = this.getPostButton();
badgeText.setBadgeText("");

}
});


I want to be able to create a List view and submitActivityForm function and append it to my Activity view.

How do I do this? Ext.Viewport.add(.... Creating a List) is not working.

scottmartin
10 Aug 2012, 1:34 PM
Please format your code in the future using [ code ] [ /code ] blocks (no spaces)

Scott.

vikramiyer
10 Aug 2012, 8:29 PM
Alright I didn't know such a thing existed. Will do that in future