PDA

View Full Version : [CLOSED] HTML Editor - Change Event ?



xtoolz
Sep 11, 2015, 1:46 PM
Hi all

I'm looking for a way to check the input length of a HTML Editor. The check should be done on each keystroke...
I found the 'change' Event in the Ext.JS doc's (http://docs.sencha.com/extjs/5.0.1/#!/api/Ext.form.field.HtmlEditor-event-change)

Is this Event also available for Ext.Net ? Can't find him...
Is there a workaround ?

Peter

Daniil
Sep 11, 2015, 3:39 PM
Hi Peter,

Ext.NET v2 is based on ExtJS 4, not ExtJS 5.

Though, there is the change event in ExtJS 4 docs as well.
http://docs.sencha.com/extjs/4.2.1/source/HtmlEditor.html#Ext-form-field-HtmlEditor

But it never worked as developers need. It doesn't fire when a user types inside. It fires only on .setValue() which is actually documented in ExtJS docs.

This thread might help you.
http://forums.ext.net/showthread.php?19358

It is for Ext.NET v1, though. Some changes (I guess, slight changes) might be required to get it working with Ext.NET v2.

xtoolz
Sep 13, 2015, 5:37 PM
Hi Daniil

I tried the Example as it is and it doesn't trigger an event ?

I changed the code a bit


var onInitialize = function (ed) {

ed.items.each(function (item) {

item.on("click", function () {
alert(this.itemId);
});

});

};

Do I have to change something else?

Peter

Daniil
Sep 14, 2015, 2:35 PM
I guess you are dealing with this example.
http://forums.ext.net/showthread.php?19358&p=83413&viewfull=1#post83413

With Ext.NET v3 tb should be replaced with toolbar.

Here is an example.

Example

<%@ Page Language="C#" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v3 Example</title>

<script type="text/javascript">
var onInitialize = function (htmlEditor) {
htmlEditor.toolbar.items.each(function (item) {
item.on("click", function () {
alert(this.itemId);
});
});
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:HtmlEditor ID="HtmlEditor1" runat="server">
<Listeners>
<Initialize Fn="onInitialize" />
</Listeners>
</ext:HtmlEditor>
</form>
</body>
</html>

If click on the toolbar's buttons, the Click event fires. But... is it what you are looking for? I guess I referenced a wrong thread. Please have a look at this one instead.
http://forums.ext.net/showthread.php?19353

xtoolz
Sep 14, 2015, 2:51 PM
This modification works - but it is not what I'm looking for :-)
I need to check the current text length in the HTML Editor - any Idea for that ?

Daniil
Sep 14, 2015, 3:10 PM
Maybe App.HtmlEditor1.getValue().length?

xtoolz
Sep 14, 2015, 3:49 PM
Sorry, I didn't explain it clearly - I need the length while tipping in the text (kind of SMS Style on Mobile Phones 'Remaining 7 of 157 Characters')

Daniil
Sep 14, 2015, 3:55 PM
Then please review:

Please have a look at this one instead.
http://forums.ext.net/showthread.php?19353

xtoolz
Sep 15, 2015, 9:04 AM
PERFECT !
Works fine :-)