Prevent Blade from displaying something if JS condition meets

its simple and complex at the same time :) i know about server client stuff but this one lets me hangin'

What i want to achieve: Display the following piece of code ONLY if it has not been displayed 5 times already.

@if(...)
<div class="goal">
   {{ $variable }}
</div>
@endif

so i want to achieve something like

<script> if($('.goal').length < 5) { </script>
    @if(...)
<div class="goal">
   {{ $variable }}
</div>
@endif
<script> } </script>

but well.. it doesnt work ^^" is there any other way? This gets Infinite scroll appended every time so i tried working with local storage but same problem, cant check the if condition. help is gladly appreciated Regards Desory

edit: using jquery.load() function to append so sending data with it is pretty much not the way to go here i guess because i dont want to append this to the url. should i call ajax inside the callback of the load ?

Answers:

Answer

Try using directly accessing your variable and not class as class don't return length of the content,

@if(strlen($variable) > 5)
   //code goes here
@endif

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.