Welcome Guest, Not a member yet? Register   Sign In
Modal help
#1

Not sure if i'm in the right place.. But i have a site using CI4 and trying to get a modal up and running... 

The modal pops up, but contains no info... So if anyone could direct me to the right direction... Smile

Link that calls the modal
PHP Code:
<a href="" data-toggle="modal" data-target="#myModal" data-foodid="<?=$subject['food_id'];?>" data-food="<?=$food_name;?>" data-name="<?=$name;?>"  data-time="<?=$time;?>"  data-status="<?=$status;?>><i class="fa fa-eye""><?= $subject['food'?></i></a> 

The modal
PHP Code:
<div class="modal fade hide" id="myModal" role="dialog" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog modal-md" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Informasjon om matvare</h5>
            </div>
            <div class="modal-body">
                <label style="font-weight: bold;"><strong>Matvare:&nbsp;</strong></label><span class="food" id="food">ingen?</span></br>
                <label><strong>Registrert av&nbsp;</strong></label><span class="madal-name" id="food">ingen?</span> </br>
                <label><strong>Registrert dato </strong></label> </br>
                <label><strong>Status </strong></label> </br>
                <a href="#myModal" type="submit" class="btn btn-sm btn-info editlink">Endre</a>
                <a href="#myModal" type="submit" class="btn btn-sm btn-danger deletelink">Slett</a>
                <a href="#myModal" type="submit" class="btn btn-sm close" data-dismiss="modal">Lukk</a>
            </div>
        </div>
    </div>
</
div

And the javascript
PHP Code:
<script>
    $('#myModal').on('show.bs.modal', function (event) {
        var applicant = $(event.relatedTarget);
        var foodid applicant.data('foodid');
        var food applicant.data('food');
        var name applicant.data('name');
        var time applicant.data('time');
        var status applicant.data('status');

        var modal = $(this)



        modal.find('.food').text('test' food);
        modal.find('.modal-name').text(name);
        modal.find('.modal-time').text(time);
        modal.find('.modal-status').text(status);
        modal.find('.editlink').attr('src''/admin/food/edit/'+foodid);
        modal.find('.deletelink').attr('src''/admin/food/delete/'+foodid));
    });
</
script
Reply
#2

This my help you out.

CRUD CodeIgniter 4 Tutorial with Bootstrap Modal (Complete Guide)
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(05-21-2021, 02:44 AM)InsiteFX Wrote: This my help you out.

CRUD CodeIgniter 4 Tutorial with Bootstrap Modal (Complete Guide)

Thanx Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB