Closed jchouix closed 3 months ago
Understood. I will look into this. Thanks.
On Mon, 15 Jul 2024, 21:20 jchouix, @.***> wrote:
Hello, I will try to explain the problem. I had some fun with trongate_MX and wanted to create a row in a table with the following code :
- in the view file : <button mx-get="<?= BASE_URL ?>layouts/get_new_tr" mx-target="#results-tbl tbody" mx-swap="beforeend">Get new tr
in the controller file : public function get_new_tr() { echo '
'; } The problem is that the title description View and tags are automatically deleted because the temporary fragment created is populated with a parent node by default. Also, I searched and found a solution to fix this problem. I replaced the following code located between lines 304 and 307 in the public/js/trongate-mx.js fileconst tempDiv = document.createElement('div'); tempDiv.innerHTML = http.responseText;
tempFragment.appendChild(tempDiv)
with this code
const tempDOM = new DOMParser().parseFromString(http.responseText, "text/xml"); tempFragment.appendChild(tempDOM.firstChild);
I also deleted the code located on line 322 tempDiv.innerHTML = ''; So, I don't know if there is a better solution but this one works. Best regards.
— Reply to this email directly, view it on GitHub https://github.com/trongate/trongate-framework/issues/190, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAUDVL2BCHB6PIZ6ES3KYTZMQVH5AVCNFSM6AAAAABK5HNS52VHI2DSMVQWIX3LMV43ASLTON2WKOZSGQYDSNJVGEYDQNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
trongate commented 3 months agoUPDATE: I have vastly improved the 'mx-target' attribute on Trongate MX. Full documentation is available from: https://trongate.io/docs/trongate-mx/targeting-elements.html.
I hope this solves your issue.
Please do confirm if you're cool or if you need further assistance.
trongate commented 3 months agoI think we're solved. If not, please reopen.
Hello, I will try to explain the problem. I had some fun with trongate_MX and wanted to create a row in a table with the following code :
<button mx-get="<?= BASE_URL ?>layouts/get_new_tr" mx-target="#results-tbl tbody" mx-swap="beforeend">Get new tr</button>
in the controller file :
public function get_new_tr() { echo '<tr><td>title</td><td>description</td><td><a href="#" class="button alt">View</a></td></tr>'; }
The problem is that the<tr>
and<td>
tags are automatically deleted because the temporary fragment created is populated with a parent<div>
node by default. Also, I searched and found a solution to fix this problem. I replaced the following code located between lines 304 and 307 in the public/js/trongate-mx.js filewith this code
I also deleted the code located on line 322
tempDiv.innerHTML = '';
So, I don't know if there is a better solution but this one works. Best regards.