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

Parent component only pass the dynamic v-modal ID to the child of the first page in pagination #5500

Closed
MuaathAlhaddad opened this issue Jun 14, 2020 · 3 comments

Comments

@MuaathAlhaddad
Copy link

MuaathAlhaddad commented Jun 14, 2020

I am using vue@2.6.11 and bootstrap-vue@2.11.0

I am having a component called index.vue to list all customers.
and a child component customerModal.vue to control the v-modal for Edit and Create Cusotmer form.

I am using v-table to list the customers details with button actions

index.vue //customer create btn

<!-- {{-- CREATE CUSTOMER --}} -->

    <b-button   @click="$root.$emit('bv::show::modal', 'customerModal' , $event.target)"  variant="success" title="Create New Customer">
        <i class="fas fa-plus-circle" id="action-icon" style="right:3%"></i>
    </b-button>  

    <!-- Modal Customer -->
    <customer-modal   :customers="customers"   modalType="create" @create-customer="customers.push($event)"></customer-modal>

index.vue //customer edit btn

<b-table
    show-empty 
    :filter="filter"
    @filtered="on_filtered"
    id="customers-table" 
    :sort-by.sync="sort_by"
    :sort-desc.sync="sort_desc"
    :items="customers" 
    :fields="fields" 
    :per-page="per_page" 
    :current-page="current_page" 
    responsive
    hover
    head-variant="light"
    class="text-center mt-4"
    >
        <template v-slot:cell(actions)="data">      
            <div class="btn-group" role="group">

                <!-- {{-- EDIT CUSTOMER --}} -->
                <b-button   @click="$root.$emit('bv::show::modal', data.item.first_name.replace(/\s/g, '')+data.item.id, $event.target)" variant="primary" title="Edit Customer">
                    <i class="fas fa-edit"></i>
                </b-button>

                <!-- Customer Modal-->
                <customer-modal  modalType="edit" :selectedCustomer="data.item" :customers="customers" @update-customer="data.item = $event"></customer-modal>
                
            </div>                
        </template>

index.vue //b-pagination

            <b-pagination
                        class=" m-auto justify-content-center"
                        pills
                        :per-page="per_page"
                        :total-rows="rows"
                        v-model="current_page"
                        aria-controls="#customers-table"
                        
                    >
            </b-pagination>

customerModal.vue

       <b-modal
            :id="this.customer.first_name.replace(/\s/g, '')+this.customer.id || 'customerModal'"
            title="Customer Modal"
            @hidden="resetModal"
            hide-footer
        >

The problem

when I go to next page using b-pagination the btn edit does not show the corresponding v-modal. While in the first page all edit btns for each customer are working just fine.

enter image description here

However if I add the create btn to the list in the second page, it will work fine
enter image description here

@MuaathAlhaddad MuaathAlhaddad changed the title b-pagination does not emit IDs of v-modal to the child when changing page Parent component only pass the dynamic v-modal ID to the child of the first page in pagination Jun 15, 2020
@Hiws
Copy link
Member

Hiws commented Jun 15, 2020

If you can create a reproduction of the issue in a codepen or codesandbox, it would be easier for us to try and debug the issue.

You can export to codepen or codesandbox from the playground for a ready to use template.

@MuaathAlhaddad
Copy link
Author

MuaathAlhaddad commented Jun 15, 2020

https://codepen.io/muaath-esmail-al-haddad/pen/wvMzwJw?editors=1111

@Hiws
I have uploaded the target code here, But I am sorry I had an extra error where the modal can not be triggered by edit at all and I could not solve it the playground.

@Hiws
Copy link
Member

Hiws commented Jun 15, 2020

I've answered on your StackOverflow question with what i think the issue is, hope it works for you.

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

2 participants