1. Fabrik 3.7 is now available. This version contains critical security updates, please update as soon as possible. Please remember to backup your site before updating, we also recommend testing your updates on development sites if possible.

Ajax deletion

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

  1. tali

    tali Member

    Level: Supporter
    Hi,
    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):

    ?option:com_fabrik&ids[3025]:3025&listid:17&listref:19_com_fabrik_19&Itemid:282&fabrik_referrer:842b3c52d936b4e1c8abd3c0d480fa6c:1&format:h&ml&packageId:0&task:list.delete&incfilters:1
    Is there a simple way to have something like
    Code (Text):

            $model = JModelLegacy::getInstance('list', 'FabrikFEModel');
            $model->setId(le n° de la liste);
            $model->deleteRows($ids);
    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