Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy "hide until rendered" option #773

Closed
scriby opened this issue Dec 20, 2012 · 5 comments
Closed

Easy "hide until rendered" option #773

scriby opened this issue Dec 20, 2012 · 5 comments

Comments

@scriby
Copy link

scriby commented Dec 20, 2012

Hi,

We use inline templates, and with base knockout there's a flashing effect as the base HTML gets bound into the rendered template. An approach I've adopted is to add this to the root element I'm binding against:

<div id="binding-start" style="visibility:hidden" data-bind="attr: { 'style': 'visibility:visible' }" />
(I used to do style: '', but oddly it doesn't work in IE8, so I had to go with the more verbose form shown)

I would love it if knockout could provide some base way to the "hide until rendered" functionality. Something like this would work well for us, but there are probably some other options:

<div id="binding-start" class="ko-not-rendered">

We can define the ko-not-rendered class to be hidden in our stylesheet, and knockout can remove the class when it binds.

Thanks for considering this,

Chris

@gmac
Copy link

gmac commented Feb 6, 2013

+1. This is a very common display issue with using Knockout templates. While there are workarounds (like the one mentioned above), the intent behind them is not obvious. Given that templating is a staple concept within the Knockout system, it would be really nice if the framework prescribed an approach here.

@alexdresko
Copy link

I'm also looking for a solution to this. I have some ideas and haven't done exhaustive research, but figured I'd show some interest in this thread.

@paglias
Copy link
Contributor

paglias commented Feb 27, 2013

This could be easily fixed using afterRender to remove a class that hide the element until it has been rendered

@jrsearles
Copy link

I like the idea of this. I definitely think it'd be useful. You could pretty easily do this with a simple binding like this:

ko.bindingHandlers["showOnBind"] = {
    init: function(element, valueAccessor) {
        var value = ko.unwrap(valueAccessor());
        if (value) {
            $(element).css("visibility", "visible");
       }
    }
};
<div id="binding-start" style="visibility:hidden" data-bind="showOnBind: true" />

basically what you are already doing but in a way that is more explicit.

@SteveSanderson
Copy link
Contributor

To help us focus on more highly-prioritised issues, we're tidying up our issue backlog. We're closing the oldest feature requests that don't have pull requests and score very low on our triage ranking system. The low triage score for this feature request suggests we should focus our finite resources on other issues. For more details, see here. Thanks for posting this feature request though. If you still actively want this feature, please reopen this issue, or post a new one (and ideally, be prepared to supply a pull request if we agree the feature would be accepted). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants