• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Plugin Development: AJAX form without PAGES_WITH_OBJECTS

    Scheduled Pinned Locked Moved
    General
    2
    4
    566
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • imt_fogI
      imt_fog
      last edited by

      Hi everyone,

      for our new local plugin, I am using a single page without PAGES_WITH_OBJECTS, as we have several different database entities to manage on that one page. I had to look deeply into sources but got it almost up and running.

      I noted that there is some hook (I think in the fog.js part) to get “normal POST forms” to work as AJAX forms and it seems to be related to action boxes and PAGES_WITH_OBJECTS.

      This brings me to my quick question: how can I use AJAX forms on a more generic page?

      Thanks and BR
      Martin

      1 Reply Last reply Reply Quote 0
      • Tom ElliottT
        Tom Elliott
        last edited by

        You can use the examples of how we use Ajax and what calls/forms they use to generate your own Ajax based script. I think this would do what you want/need and still allow you to use the hook for the tie in.

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        imt_fogI 1 Reply Last reply Reply Quote 0
        • imt_fogI
          imt_fog @Tom Elliott
          last edited by

          @Tom-Elliott That’s what I tried the last two days, I am literally “poking in the FOG” sources 🙂 I more or less got the backend part with FOGPage, FOGBase, FOGController and most of the reflections used, but the JS frontend is a bit mysterious from time to time…

          Lets e.g. use this form as an example:
          https://github.com/FOGProject/fogproject/blob/348f695c3def03050877c4919e2041f2cf91b965/packages/web/lib/pages/storagemanagementpage.class.php#L1316

          What does it make to use AJAX? There is some jQuery magic going on to prevent the default submit event, that’s pretty clear. Unfortunately, it is hard to find out why this is happening. Right now I am assuming setupTimeoutElement() is setting the submithandlerfunc to intercept the form submit, and then one is doing the AJAX stuff?

          I’ll give it a try on my dev machine tonight…

          1 Reply Last reply Reply Quote 0
          • Tom ElliottT
            Tom Elliott
            last edited by

            It’s been a while since I wrote that code and I’ve been working hard on trying to get 1.6 to a more functional state (which I believe it’s mostly there now.)

            Of note, while you can tie into the common ajax code sitting within for setupTimeoutElement and submithandlerfunc, the common thing to be noted is that you can have your JS code do whatever you need. Those methods are available, but there’s no 100% dedication to using it. Use it where you can, but it’s not a requirement.

            The js code get’s loaded automagically in 1.5 via node and sub in the get request.

            So let’s say you wanted js code to alter the list page for some reason. Your plugin node code would be say exampleplugin. You would simply need a file named: fog.exampleplugin.list.js (file names are always: fog.<node>.<sub>.js)

            Hopefully this makes sense.

            So in keeping with that file scheme, common files I can think of for a plugin named exampleplugin would be:

            fog.exampleplugin.js //base js for all exampleplugin node items.
            fog.exampleplugin.list.js //exampleplugin's list page.
            fog.exampleplugin.add.js //exampleplugin's create/add item page.
            fog.exampleplugin.edit.js //exampleplugin's edit item page.
            

            While I’m sure this doesn’t answer any of your questions, it should help with getting something functional.

            You can use other plugin’s to help in the understanding of the js files too. A common one I like to use that interacts with both groups and hosts is the location plugin. This should give a pretty good understanding of what to do, and how to do it. If you still have questions please ask and try to be detailed in exactly what you’re looking for.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post

            154

            Online

            12.0k

            Users

            17.3k

            Topics

            155.2k

            Posts
            Copyright © 2012-2024 FOG Project