Coder Social home page Coder Social logo

Render query isn't working about jsblocks HOT 12 CLOSED

astoilkov avatar astoilkov commented on September 2, 2024
Render query isn't working

from jsblocks.

Comments (12)

zombiQWERTY avatar zombiQWERTY commented on September 2, 2024

And ifnot query is not correctly working

from jsblocks.

astoilkov avatar astoilkov commented on September 2, 2024

Could you provide more information on your scenario. There are tests about render and ifnot which are passing for every built and I guess that it some custom scenario that's failing.

from jsblocks.

zombiQWERTY avatar zombiQWERTY commented on September 2, 2024

Here is my console with errors
http://oi59.tinypic.com/dh5y6r.jpg
The variable "fullLayout" is bollean

from jsblocks.

astoilkov avatar astoilkov commented on September 2, 2024

Yeah. I understand now. The console messages are not correct but I have already fixed them couple of weeks ago but they are still not part of any release. I will create a release next week. For the error render() is support only in each() query - this means that render() could be called only inside each() binding because it is not useful elsewhere. I will show an example:

<ul data-query="each([1, 2, 3])">
  <!-- render() could be used here -->
  <li data-query="render(true)"></li>
</ul>

from jsblocks.

zombiQWERTY avatar zombiQWERTY commented on September 2, 2024

Ok, understood. But what about ifnot query?
And I need to function like Angular ng-if for partial rendering depending on different conditions. How can I do it?

from jsblocks.

astoilkov avatar astoilkov commented on September 2, 2024

ifnot query is working. It just logs incorrect messages to the console. This is fixed in the latest code. You could use visible() query to show and hide particular sections.

from jsblocks.

zombiQWERTY avatar zombiQWERTY commented on September 2, 2024

Ok, thank you. Closed

from jsblocks.

quantumlink avatar quantumlink commented on September 2, 2024

Seems to me that the ability to conditionally not render elements in a view based on values from the view instead of just having to use visible() which just hides them using CSS is valuable and render() could be used for that.
One simple case I can think of is if there is an img tag where the model's value for the source is falsey and it would be nice to just not include the img tag at all instead of just hiding it.
In that case it would be <img data-query="render(profile_img)" src="{{profile_img}}">.
Perhaps there is another way to do this in jsblocks that I'm missing.

from jsblocks.

astoilkov avatar astoilkov commented on September 2, 2024

Thanks for the idea.

What the benefit of removing the element would be? Are you using server-side rendering?

from jsblocks.

quantumlink avatar quantumlink commented on September 2, 2024

In this case I'm not using server-side rendering, was just looking for a solution the client-side that would allow me to exclude the element conditionally. A case would be if I loaded some data from localstore after a route change let's say and wanted to not include an element conditionally. I can see how in most cases visible is what you want, but in some cases, img tags being one, it's nice to have control over if the element shows up at all. I suppose I could just use some JS to remove the element from the logic in the view, but it would be nice to be able to have a data-query that allowed conditionally including elements.

from jsblocks.

astoilkov avatar astoilkov commented on September 2, 2024

Ahaa. Ok. I understand now. I agree and have created an issue for this here.

from jsblocks.

quantumlink avatar quantumlink commented on September 2, 2024

👍 Really enjoying working with this framework, thank you for all your effort.

from jsblocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.