trying to data-bind css in knockout

I have a jQuery UI Dialog that has a div element.

I'd like to make this div to show or not by data-binding css in knockout.
Below is the part of the element div:

<div data-bind="css: $parent.shouldShowTopicError">
    <span>* Topic Description cannot be empty</span>
 </div>


I have a function in my viewModel that I call shouldShowTopicError to either show or hide this div.

Below is part of the function in my ViewModel:
           ViewModel = (function () {
            self = this;
           
            showTopicError = ko.observable(''),
            shouldShowTopicError = function () {
                showTopicError('dontShowTopicError');
            }

            return {
                showTopicError :showTopicError ,
                shouldShowTopicError: shouldShowTopicError
                    }
            })(); // end of viewModel

            ko.applyBindings(ViewModel);


dontShowTopicError is a css class that I assign to my showTopicError  observable.

I cannot get it to work.
I appreciate the help.

Thanks
Rainsee65Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
Test page : http://jsfiddle.net/Lg5pn6xh/
Doc : http://knockoutjs.com/documentation/css-binding.html

<div data-bind="css: { dontShowTopicError: showTopicError }">
    <span>* Topic Description cannot be empty</span>
 </div>
<script>
ViewModel = (function () {
            self = this;
            // hidden by default :
            self.showTopicError = ko.observable(true);

            return {
                showTopicError: showTopicError 
            }

    })(); // end of viewModel

            ko.applyBindings(ViewModel);
            setTimeout(function() {
                ViewModel.showTopicError(false);
            }, 5000); // display it after 5s
</script>

Open in new window


.dontShowTopicError {
    display:none;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rainsee65Author Commented:
I've requested that this question be deleted for the following reason:

I found the answer thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.