sagemath / sagecell

The Sage Cell Server---providing a way to embed Sage computations into any web page.
Other
201 stars 70 forks source link

Accessing sagecellInfo object #543

Closed ro70 closed 3 years ago

ro70 commented 3 years ago

Why do I see a sagecellInfo content but having no access to it?

var sagecellInfo = sagecell.makeSagecell({
          inputLocation: '#' + sagecellId,
          evalButtonText: 'go',
          code: code,
});

console.log(sagecellInfo)
console.log(sagecellInfo.code)  // <== undefined
grafik

EDIT: Seems to be an async thing. I'm calling the sagecellInfo.code too early. I could set a callback function in makeSagecell. But how can I access the sagecellInfo just created from there?

novoselt commented 3 years ago

Indeed it is because of asynchronous calls. I imagine that if you create a variable to make it available inside your call back function and then call makeSagecell with a callback argument, you will have access to it.