PDA

View Full Version : [CLOSED] Can not change EmptyText



jchau
Jan 25, 2013, 9:54 PM
When you set EmptyText, it injects the old EmptyText as the text value of the textfield. It's very subtle but after you press Change Empty Text, put your cursor in the textbox.

The only workaround is to set the Empty Text and if the textfield was empty in hte first place, clear it.



<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<style type="text/css">

</style>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" ScriptMode="Debug" Theme="Gray"
DisableViewState="true" />
<ext:TextField runat="server" ID="txtField" EmptyText="Initial Empty Text" Width="300">
</ext:TextField>
<ext:Button runat="server" Text="Change Empty Text">
<Listeners>
<Click Handler="#{txtField}.emptyText = 'New Empty Text';">
</Click>
</Listeners>
</ext:Button>
</form>
</body>
</html>

Baidaly
Jan 25, 2013, 11:11 PM
Hello!

Sorry, I don't quite understand you. What's your problem?

If the problem is that you have to focus and blur textfield to show new EmptyText? You can try to call applyEmptyText



<Click Handler="#{txtField}.emptyText = 'New Empty Text'; #{txtField}.applyEmptyText(); ">
</Click>

jchau
Jan 26, 2013, 3:47 AM
The empty text is not changed when you call textField.emptyText = "Some Text".

Daniil
Jan 26, 2013, 3:59 AM
As far as I can know there is no any mechanism in JavaScript to get something updated just after updating a JavaScript object's property.

I mean that there is no "setter" where it would be possible to run some additional JavaScript code to update the required things.

So, calling the applyEmptyText method should be a solution.