trongate / trongate-framework

The Trongate PHP framework
https://trongate.io
Other
1.09k stars 97 forks source link

issue with trongate-mx #190

Closed jchouix closed 1 month ago

jchouix commented 1 month ago

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 :

trongate commented 1 month 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 'titledescriptionView'; } The problem is that the 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 file

    const 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 1 month ago

UPDATE: 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 1 month ago

I think we're solved. If not, please reopen.