Open xshuai1006 opened 2 years ago
Do you also happen to use something like [[]]
or [[#]]
in your queries? This also happened to me.
I think it has something to do with Dataview's caching mechanism, where it will cache the result of same query statements.
Dataview doesn't cache - it's Obsidian doing this in this case. Codeblocks with exactly the same contents are cached by the Obsidian markdown renderer to be the same view.
You can fix this by adjusting one codeblock - reference a file by name, insert spaces, adjust names, adjust titles, and so on. It's very frustrating, but I haven't found a good fix for it yet sadly.
Dataview doesn't cache - it's Obsidian doing this in this case. Codeblocks with exactly the same contents are cached by the Obsidian markdown renderer to be the same view.
You can fix this by adjusting one codeblock - reference a file by name, insert spaces, adjust names, adjust titles, and so on. It's very frustrating, but I haven't found a good fix for it yet sadly.
Oh that's great to know
@blacksmithgu Brilliant! ๐
Is there a way to dynamically make the code blocks different, for js blocks?
I have requirement where the same code block runs on pages, but the result depend on the attributes on the page - if I could make each different as part of the data view js code, that would be AMAZING!
Check out dv.view()
from the documentation.
Check out
dv.view()
from the documentation.
Ooo ๐ is this same script format as standard templater scripts?
I assume Obsidian canโt cache code blocks using scripts?
Not sure what you mean by caching code blocks but the view.js
is standard JS.
Not sure what you mean by caching code blocks but the
view.js
is standard JS.
Caching, as in comment above;
Dataview doesn't cache - it's Obsidian doing this in this case. Codeblocks with exactly the same contents are cached by the Obsidian markdown renderer to be the same view.
Oh my, I think I've completely misunderstood the original ask. In this case, you probably want to listen on an event. You can use that event to trigger a refresh using dv.index.touch()
. You can get the currently active file via app.workspace.getActiveLeaf()
or something related. Hopefully, this gives you enough ideas to go looking but I'd need some time to figure out what this use case properly looks like.
Hello, sorry to come back to you so late. I currently go through older issues to see which are stale or already solved.
Does AB1908 suggestion fix the use case for you?
What happened?
Table contents of a note (in live preview mode): Switch to b note (still in live preview mode): table content is the same with a note above And this is the real table content of b note (switch to preview mode):
DQL
No response
JS
No response
Dataview Version
0.4.26
Obsidian Version
0.14.2
OS
Windows