ExtJS 4: HtmlEditor Clear All Tags Button

Posted By Vitalii | February 02, 2014 | ExtJS 4.2.2
0 3592
We can make this button as a simple plugin for HtmlEditor.

Js Code

Ext.define('Ext.form.plugin.ClearTags', {
    regex: /(<([^>]+)>)/ig,
    regexSpaces: /(\s|&nbsp;)+/g,
    ...
    onRender: function () {
        ...
        tb.add({
            ...
            handler: function () {
                var value = ed.getValue() || '',
                    result = value.replace(me.regex, ' ').replace(me.regexSpaces, ' ');
                ed.setValue(result);
            }
        });
    }
});
            

ExtJS 3: HtmlEditor Clear All Tags Button

Posted By Vitalii | February 02, 2014 | ExtJS 3.4.0
0 3229
We can make this button as a simple plugin for HtmlEditor.

Js Code

Ext.form.plugin.ClearTags = Ext.extend(Ext.util.Observable, {
    regex: /(<([^>]+)>)/ig,
    regexSpaces: /(\s|&nbsp;)+/g,
    ...
    onRender: function () {
        ...
        tb.addButton({
            ...
            handler: function () {
                var value = ed.getValue() || '',
                    result = value.replace(me.regex, ' ').replace(me.regexSpaces, ' ');
                ed.setValue(result);
            }
        });
    }
});
            

How To Reload Window Content

Posted By Vitalii | April 03, 2012 | ExtJS 4.0.7
1 3621
Reply to thread

Js Code

Ext.widget('window', {
	title: 'Test window',
	autoShow: true,
	width: 300,
	height: 150,
	bodyStyle: { 'background-color': '#FFFFFF', 'padding': '10px' },
	autoLoad: { url: '/postdata/getcontent/1' },
	tbar: [{
		text: 'Reload',
		handler: function () {
			var win = this.up('window');
			win.loader.load(win.autoLoad.url);
		}
	}, {
		text: 'Reset',
		handler: function () {
			var win = this.up('window');
			win.update('<b>Init</b> content');
		}
	}]
});
            

Window FAQ: Confirm Window Closing

Posted By Vitalii | March 31, 2012 | ExtJS 4.0.7
0 2660
This example shows how to close window only after user confirmation.

Js Code

Ext.widget('window', {
	title: 'Test Window',
	html: 'Close Me',
	width: 400,
	height: 200,
	bodyPadding: 10,
	autoShow: true,
	onEsc: Ext.emptyFn,
	listeners: {
		beforeclose: function () {
			if (this.confirmed === true) {
				this.confirmed = false;
				return true;
			}
			Ext.Msg.confirm('Test Window Closing...', 'Are you sure?', function (button) {
				if (button == 'yes') {
					this.confirmed = true;
					this.close();
				}
			}, this);
			return false;
		}
	}
});