Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render query isn't working #58

Closed
zombiQWERTY opened this issue Jun 19, 2015 · 12 comments
Closed

Render query isn't working #58

zombiQWERTY opened this issue Jun 19, 2015 · 12 comments

Comments

@zombiQWERTY
Copy link

No description provided.

@zombiQWERTY
Copy link
Author

And ifnot query is not correctly working

@astoilkov
Copy link
Owner

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.

@zombiQWERTY
Copy link
Author

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

@astoilkov
Copy link
Owner

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>

@zombiQWERTY
Copy link
Author

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?

@astoilkov
Copy link
Owner

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.

@zombiQWERTY
Copy link
Author

Ok, thank you. Closed

@quantumlink
Copy link

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.

@astoilkov
Copy link
Owner

Thanks for the idea.

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

@quantumlink
Copy link

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.

@astoilkov
Copy link
Owner

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

@quantumlink
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants