loading a knockout.js observableArray() from .ajax() call

后端 未结 5 1294
半阙折子戏
半阙折子戏 2021-02-01 20:10

This puzzles me. It must be something small I\'m not seeing. I\'m trying to load a very simple observableArray in knockout with an ajax call.

javasc

5条回答
  •  忘掉有多难
    2021-02-01 20:40

    We can use a simple JavaScript util function as a work-around.

    Instead of viewModel.vendors(data);, wrapping with eval (research the dangers of eval first) will work.

    eval("viewModel.vendors("+JSON.stringify(data)+");");
    

提交回复
热议问题