jeudi 29 décembre 2016

Laravel5.1 can you passed an incremental variable in to a sub-view

I am trying to pass an incremental variable to a blade template subview to add a number to a class name.

@for($x=1; $x < 4; $x++)
            <div class="col-md-3">
                {!! Form::label('amenIcon'.$x,'Amenity Icon '.$x) !!}
                {!! Form::select('amenIcon'.$x,
                 [null =>'Choose Icon'] + $iconDirectory)
                    !!}
            </div>
                @include('portal._iconModals')
            @endfor

The sub-view portal._iconModals

div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Choose Icons</h4>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-md-12" id="bsnImage">
                    @foreach($brandSocialIcons as $bIcons)
                        <a href="javascript:void(0);" class="iconChoice"><img src="../../../../storage/icons/"></a>
                    @endforeach
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
</div>

I would like to increment the class name iconChoice because the I have 3 select fields with options that use the same subview but because of the class name when I choose one of the images with the class of iconChoice it chooses it for all 3 select list instead.

Here is the js code $( "#amenIcon1" ).click(function() {

     $('.iconChoice').click(function() {
         var $thumb = $(this);
         console.log($thumb);

         var icon1 = $thumb.find('img').attr('src');
         displayIcon1(icon1)
     });
     function displayIcon1(icon1) {
         $("#icon1Thumb").attr("src",icon1);
     }
 });

Might not be the best explanation but I will to elaborate more if need be. Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire