Skip to content

A double insertion occurs when using mx-select-oob with trongate-mx. #241

Description

@jchouix

Hi DC,
I encountered an issue while writing this code :

<?php   
$btn_attrs = array(
    'mx-get' => 'http://trongatev2.fr/tasks/show/2',
    'mx-select' => ".card-body",
    'mx-target' => ".task-content",
    'mx-select-oob'=> json_encode([
        ["select" => ".card-heading", "target"=> ".task-heading", "swap"=> "beforeend"],
        ["select" => ".card-footer a.button.edit", "target"=> ".task-footer", "swap"=> "afterbegin"]
    ])
);

echo form_button('show_task_btn', 'Show a Task', $btn_attrs);
?>
<br>
<br>
<h1>Response</h1>
<div class="task-heading"></div>
<div class="task-content"></div>
<div class="task-footer"></div>

Specifically, a double insertion occurred (see screenshot).
I investigated the cause of the bug and found that the function handleOobSwaps() is being called twice (at lines 418 and 719 of the trongate-mx.js file).
Removing line 719 fixes the issue (please verify this yourself).
Best regards.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions