I have some inline JS that enables/disables one field (toggles between “read” and “readonly”) based on the value of another field. The fields are both in a popup. The code works, but only once the popup has come up and I’ve set/reset the controlling field. I can’t get it to initially enable/disable the controlled field. Here is the code, taken from a sample that Zach gave me. It works perfectly elsewhere, but doesn’t work initially for my popup. ---------- snip, snip ---------- (function(skuid){ var $ = skuid.$, $M = skuid.model.map(); $(function(){ var AccountModel = $M.NewAccount, Account = AccountModel.getFirstRow(); // Register a listener on the Status field. // When it is changed, we may need to rerender some fields // to make them read-only. var listener = new skuid.ui.Field(Account,AccountModel,null,{ fieldId: ‘Status__pc’, register: true }); var fieldsToDisable = [‘Death__pc’]; var deathHandleChange = function(newValue){ $.each(AccountModel.registeredLists,function(){ $.each(this.renderedItems,function(){ $.each(this.fields,function(){ if ($.inArray(this.id,fieldsToDisable)!==-1){ if (newValue == ‘Deceased’) this.mode = ‘edit’; else { this.mode = ‘readonly’; } AccountModel.updateRow(Account,this.id,‘’,{initiatorId: this._GUID}); this.element.empty(); this.render(); } }); }); }); }; listener.handleChange = function(newValue){ deathHandleChange(newValue); }; // Run the handle change initially deathHandleChange( AccountModel.getFieldValue(Account,‘Status__pc’,true) ); }); })(skuid); ---------- snip, snip ----------
Question
inline snippet to enable/disable field(s) in a popup - works, but only after field changed
This topic has been closed for replies.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.