The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

EZPA55 (1) [Avatar] Offline
#1
Can someone please tell me how to add the ability to specify any styles to the states read/write. Thanks still very much an amateur here.
KAES (14) [Avatar] Offline
#2
Re: 7.4 Extra Credit - Modify the method to accept any styles
Someone please feel free to chime in.

Would the correct way to do this be to create a JS object to map the .css() api or to use the $.extend() outlined in 7.2.3 ?
KAES (14) [Avatar] Offline
#3
Re: 7.4 Extra Credit - Modify the method to accept any styles
(function($){
$.fn.setReadOnly = function(readonly) {
var cssObj ={ /*added*/
'opacity': readonly ? 0.5 : 1.0,
'background-color': readonly ? 'red' : 'white'
}
return this.filter('input:text')
.attr('readOnly',readonly)
.css(cssObj)
.end();
};
})(jQuery);