rguliev / conditionize2.js

jQuery plugin for conditioning things
https://rguliev.github.io/conditionize2.js/demo/index.html
MIT License
22 stars 6 forks source link

Doesnt work with backwards ( \) #15

Closed skalero01 closed 3 years ago

skalero01 commented 3 years ago

Apparently this doesnt work

<div class="col-sm-12">
    <div class="form-group">
        <label class="form-label">Precio De Tipo</label>
        <select name="priceable_type" class="form-control">
            <option value="">Seleccionar opción</option>
            <option value="App\Models\Course" selected="selected">Curso</option>
            <option value="App\Models\Product">Producto</option>
        </select>
    </div>
</div>
<div data-condition="priceable_type=='App\Models\Course'"">
    Access
</div>

Or it works on your side? I am using 2.0.1 version on the cdn

rguliev commented 3 years ago

Hi @skalero01

I would say that the reason is your condition. Try console.log('App\Models\Course') it will return AppModelsCourse because \ is considered to be an escaping symbol. In order to put slash you should use \\, i.e. try data-condition="priceable_type=='App\\Models\\Course'"

skalero01 commented 3 years ago

Didnt work neither

rguliev commented 3 years ago

Tried again on my side and it works. Can you provide a non-working codepen (or something similar)? Here is my code:

<body>
    <div class="col-sm-12">
        <div class="form-group">
            <label class="form-label">Precio De Tipo</label>
            <select name="priceable_type" class="form-control">
                <option value="">Seleccionar opción</option>
                <option value="App\Models\Course" selected="selected">Curso</option>
                <option value="App\Models\Product">Producto</option>
            </select>
        </div>
    </div>
    <div data-condition="priceable_type==='App\\Models\\Course'">
        Access
    </div>
    <script>
        $('[data-condition]').conditionize();
    </script>
 </body>
rguliev commented 3 years ago

@skalero01 so, did it work?