Ajax loaded data doesn't update layout

I load data using ajax and populate my page using Knockout. This all works great, when I changes pages to `#contacts` it looks good. However, I have a problem when the #contacts page is the initial page i load. E.g. if I load `www.mydomain.com/#contacts`, the initial page loaded is the list page, thus the `ko.bindinghandlers.listview` doesn't have any affect. I tried re-creating the page, but that doesn't fully work either, not all the styles are applied as it should. My list view is not just a list view, it contains a controllgroup as well, to make a list view with checkboxes. $("#contacts").page('destroy').page(); $('#contacts').bind('pageinit', function() { $('ul').listview(); }); How can I load data using Ajax, append it (using ko) to my `ul` and have it render correctly. This is how it looks if `#contacts` is NOT the initial page loaded: ![Correct][1] This is the best result I manage to get this far, when `#contacts` IS the initial page loaded: ![Incorrect][2] [1]: http://i.stack.imgur.com/JDYv4.png [2]: http://i.stack.imgur.com/VJCvJ.png
I’m just guessing, but maybe bind the handler before calling .page()?

以上就是Ajax loaded data doesn't update layout的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏