开发者

Preventing validator from firing after bound value changes

开发者 https://www.devze.com 2022-12-10 03:36 出处:网络
I am working on a product options form whose contents should be cleared by a clearOptions() method each time the user adds an option.The option name TextInput is bound to a value object that is reinst

I am working on a product options form whose contents should be cleared by a clearOptions() method each time the user adds an option. The option name TextInput is bound to a value object that is reinstantiated each time the the user adds a product option. The problem I am having is that the Stri开发者_如何学CngValidator fires each time the bound value object is reinstantiated.

<mx:StringValidator id="valOptionName" minLength="1" source="{txtOptionName}" property="text" trigger="{btnAddChangeOption}" triggerEvent="click"/>

<mx:TextInput id="txtOptionName" width="120" text="{currentProductOption.name}"/>

<mx:LinkButton id="btnAddChangeOption" label="Add/Change Option" click="saveUpdateOption(event)" horizontalCenter="0"/>

The following code is what causes the StringValidator to fire when it shouldn't. It results in a red outline around a text box.

private function clearOptions():void
{
    currentProductOption = new ProductOptionVO();
}

Thank you for any help,

Orville


I solved the problem by setting the source of the validator manually in the validation code and then switching it off before currentProductOption is reinstantiated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号