getHtmlData used with your own DIVs

Hi,
I'm editing a page I made in boonex in a custom module. The page is composed of columns, each of which has a "pageBlock" as per Boonex definition, so each pageBlock is declared in the db.

Now, my central column contains a number of DIVs created by my PHP code. One of those DIV lists the available images and it's called "availableImagesDiv". The DIV is not a pageBlock, it's just a normal div inside the page, created by code.

I would like to use getHtmlData to have that DIV reload it's content when clicking on a link.

I have in my code a function called: getBlockCode_ListImages($iBlockID); which generates the content of it.

and in the page I have a link with an URL like this:

<a href='null' onclick="getHtmlData( 'availableImagesDiv', 'http://<myserver>/boonex/home?action=viewObject&oID=281&dynamic=tab&pageBlock=ListImages', false, 'post');return false;">test</a>";

But it doesn't work.

The only way I managed to have it working is to add one entry in sys_page_compose table with Func='ListImages' and ID 318, then use the following URL instead:

<a href='null' onclick="getHtmlData( 'availableImagesDiv', 'http://<myserver>/boonex/home?action=viewObject&oID=281&dynamic=tab&pageBlock=318', false, 'post');return false;">test</a>";

This works but is not what I want as this forces BxDolPageView to generate a new block in my page while I have it generated by my code.

In summary is there a way to use getHtmlData to call a function you want and substitute the content of a div in the page?

Thanks.

Quote · 14 Jan 2013

getHtmlData JS function can be used to load any data loadedc via JAX request to a HTML container(div). 

If you are calling this function to load page block it is usually loaded with the box, however you can turn off the block if you edit sys_page_compose table row for the necessary block and set DesignBox - 0.

In general DesignBox field can have the following values:

DesignBox = 0: no box

DesignBox = 1: box without padding

DesignBox = 11: box with standard padding

In summary is there a way to use getHtmlData to call a function you want and substitute the content of a div in the page?
Thanks.

 

Rules → http://www.boonex.com/terms
Quote · 15 Jan 2013

Thanks for you answer, at the end what I did is the following:

1) Edit BxDolPageView.php and add in the function getCode() at the beginning

        if ($_REQUEST['pageDiv']) {
            $functioname = "getBlockCode_".$_REQUEST['pageDiv'];
            header( 'Content-type:text/html;charset=utf-8' );
            echo $this -> $functioname((int)$_REQUEST['pageBlock']);
            exit;
        } else

2) Add the onclick event on my link like:

onclick="getHtmlData( 'availableImagesDiv', '".$this->sPageURL."?action=viewObject&oID=281&dynamic=tab&pageDiv=ListImages', false, 'post');return false;"

 

I understand it's a kind of a hack, but accomplishes what I need, which is to just fill out the div with the ajax call. I will try also your solution with Designbox=0.

 

Quote · 15 Jan 2013

Now I have another similar need, which is: I need to refresh the same DIV with ajax, but after submitting a form which is sending a file on server (an upload form). Is that possible? Can getHtmlData() be used also in a form submitting a file with POST?

In the link example above the href is actually not called, and it's just the getHtmlData() which is called. In this upload form, I need the form to actually submit the file, so the main URL should work somehow. Do you have any ideas/examples?

Looking at how Boonex does it in the standard upload form, seems the trick is to use the "target" attribute on the form and actually submit the result to an <iframe> on the page, so the current page doesn't refresh. But I'm not sure if there is a way to just avoid reading the result.

Thanks.

Quote · 15 Jan 2013

Just wondering why you have to use the default function always. Why not code your own js functions and attach it in the page?

so much to do....
Quote · 15 Jan 2013

Usually "custom = more maintenance costs" that's why I try to use the standard as much as I can.


Anyway I managed to fix the problem also for POST uploading a file. There is plenty of information on the internet on it. Seems to be a common problem.

In short, I've used the post to submit the file, while redirecting the result of the form submit to an iframe, with the "target" tag. Then in the iframe I print out the javascript code which launches getHtmlData, and in that I use the callback parameter:

function getHtmlData( elem, url, callback, method )

to call a script to refresh the controls. From the iframe, when you need to call getHtmlData on an element which is on the parent page you need to use: getHtmlData( $('#availableImagesDiv', window.parent.document), ....

Holy... has been a ride, but seems to work (Explorer included).

Quote · 15 Jan 2013
Usually "custom = more maintenance costs" that's why I try to use the standard as much as I can.

Now this is above my head...Cry 

Good Luck to you.

so much to do....
Quote · 15 Jan 2013

ah ah , don't worry, I have nearly all the rest custom and I'm sure I will need more help in the future for custom code! Laughing

Quote · 15 Jan 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.