Open hdriqi opened 7 years ago
ajax and templates are two different problem domains and yo yo doesn't aim to solve them both - unlike say jQuery.
There's a bunch of ways you can do Ajax, like the xhr
library on npm, or the new fetch api.
If your question is more about the asynchronous nature of ajax requests, can you elaborate more?
@juliangruber yes, it is more on asynchronous. For example I want to do ajax request and after that update using yo.update
What is the best way to do that, is it by doing ajax request at the root node and after the data has been received use yo.update(treeID, newTree) ??
can you maybe post a code example of what you're doing? not quite sure i follow your example
function ajaxReq(){
doAjaxRequest
.done((newData) => {
var newMain = main(newData)
yo.update(main(), newMain)
})
}
function main (data) {
return yo`
<div>
${data}
</div>
`
}
yo.update(document.body.firstChild, main())
ajaxReq()
Is this a good practice for doing ajax request?
Can someone provide best practice for ajax request and yo yo template?