1. Important notice about Cloudbleed - if your site uses the Cloudflare CDN, and you intend to follow the Joomla security team's advice to change your site "secret", you MUST READ THIS NOTICE.
  2. Fabrik 3.6 Released Remember to backup and test your backup before proceeding with this update. Please report any problems you might experience with this new version here on the forum. You are safe to upgrade to Joomla! 3.7 and PHP 7.x with this version of Fabrik. View the blog for more details on this release.

Ajax deletion

Discussion in 'Community' started by tali, Jan 6, 2017.

  1. tali

    tali Member

    Level: Supporter
    For some reasons I'd like to send an ajax request to delete row of id rowid.
    Something as what does the delete button on a row in a list.
    The URL under the button just gives /#

    Can this be done by a request like
    Code (Text):

    Is there a simple way to have something like
    Code (Text):

            $model = JModelLegacy::getInstance('list', 'FabrikFEModel');
            $model->setId(le n° de la liste);
    running on the server?
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Supporter
    Where are you trying to run this code from?

    But yes, pretty much that exact code is what you need, and the $ids just needs to be an array of row ids.

    -- hugh
  3. tali

    tali Member

    Level: Supporter
    Thank you for your reply.

    I'm trying to run this code form a list BUT this list is embedded inside a form and ajax loaded.
    In that case, it appears that by default, the X button is not working.

    I found an ajax solution to have the edit button working, but did not find a working solution for the delete button.
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Supporter
    By "embedded" you mean with the content plugin in the form intro/outro?

    Sent from my HTC 10 using Tapatalk
  5. tali

    tali Member

    Level: Supporter
    In fact, as I have several lists, the ajax call for each one is in a display element, one per list.
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Supporter
    Ah. Hmmm, no, that won't work.

    I mean, it may kind of half-assed seem to work, but is liable to cause lots of problems, because lists have HTML forms in them (which handle all the filtering, checkbox selections, action buttons and navigation), as do forms (surprise surprise). And HTML doesn't let you nest form tags. And if you do nest forms, HTML gets very confused about what form inputs belong to which form, and what you are trying to submit. Which is why your delete and edit buttons don't work.

    The only place it's safe to "embed" a list on a form is in the intro or the outro, where it is outside the form tags for the Fabrik form.

    If you are only displaying this in a details view, it'll work, as details views don't have form tags, they are just divs.

    I'm very reluctant to help you find ways to work round this, as you are liable to run into more unexpected issues, and there really is no way of safely working round a fundamental limitation of HTML forms.

    This is one of the reasons we developed our AJAX driven popup windows for displaying lists and forms, as it's a way of accessing another form or list from within a form or list, without leaving that page, but working round the "can't nest HTML forms" issue.

    -- hugh
    tali likes this.
  7. tali

    tali Member

    Level: Supporter
    Great response and well explained.
    Thank you for pointing all the ins and outs
    cheesegrits likes this.

Share This Page