admin管理员组文章数量:1302229
I'm using knockout to bind a list of images. What's the best way to set up a spinner background while the images are loading. I have a spinner class I can set and unset to the background image, but wondering if there is an easy way to bind to image plete events with knockout.js.
I'm using knockout to bind a list of images. What's the best way to set up a spinner background while the images are loading. I have a spinner class I can set and unset to the background image, but wondering if there is an easy way to bind to image plete events with knockout.js.
Share Improve this question asked May 23, 2012 at 20:44 MonkeyBonkeyMonkeyBonkey 47.9k82 gold badges270 silver badges479 bronze badges 1- malsup./jquery/block/#demos – deltree Commented May 23, 2012 at 20:54
1 Answer
Reset to default 9using jquery UIs little spinner thing, I have a binding handler like
ko.bindingHandlers.Loading = {
update: function (element, valueAccessor, allBindingsAccessor) {
var value = valueAccessor(), allBindings = allBindingsAccessor();
var valueUnwrapped = ko.utils.unwrapObservable(value);
if (valueUnwrapped == true)
$(element).showLoading(); // Make the element visible
else
$(element).hideLoading(); // Make the element invisible
}
};
and then use it like
<div data-bind="Loading: isLoading" >
so, basically, you can bind it to anything on your view model that might represent its loading ( or busy ) or not.
本文标签: javascripthow to show an image loading spinner with knockoutjsStack Overflow
版权声明:本文标题:javascript - how to show an image loading spinner with knockout.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741706715a2393603.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论