Jump to content

Page refresh for tab content


inkredible

Recommended Posts

I am afraid this is a very specific question, but I am stuck with this problem. I am building a tab based page, which is very similiar to the userpanel:

ZMFMCcp.png

I am also a function for each area (sessions, statistics, ...) and I return a template each function which will be inserted into the content area (if it's an ajax request). As you can see in this screenshot I am building a "\IPS\Helpers\Table\Custom". The problem is: Every time I click the sessions tab a second time it will trigger a full page reload. I don't experience this behaviour with other tabs, I expected that it doesn't reload/request anything at all after the tab content has been initially loaded.

I figured out that it's related to the table. This is what my _sessions() function returns:

return \IPS\Theme::i()->getTemplate( 'panel', 'botuserpanel', 'front' )->sessions((string) $table);

 

Once I don't pass (string) $table to my getTemplate it won't trigger a full page reload anymore. What can I do to prevent this issue? I can provide more code if needed.

Link to comment
Share on other sites

58 minutes ago, bfarber said:

I would start by checking the browser console tool to inspect the network request and console and make sure the response is returned in the manner expected.

Okay I have done so. There is definetely a different request when I click the "sessions" tab item (which is the only tab having this issue), but it's hard to see as this immediately reloads the page and hereby clears the network log aswell. While all other tabs result in a simple XHR request with such a URL: http://domain.com/botuserpanel/debug/?csrfKey=6120445af6750e1fa00159ed6540ee42 the sessions tab results in an index.php call like this one: http://domaint.com/index.php?&app=botuserpanel&module=userpanel&controller=userpanel&area=sessions& . I don't know where the appended & comes from, but it also does a 301-redirect to the FURL. 

I am surprised that none of these issue exists once I don't pass the $table variable into that area's template. In my oppinion this must be an incompatibility of custom tables in tabs/furls? I don't see anything I could do wrong here?

 

In my oppinion this is a bug, I have inserted my code into core/modules/front/system/settings.php (which also uses the tabsystem) and the problem is exactly the same there. Below the code inserts to reproduce the problem:

1. Replace into the _password function in /applications/core/modules/front/system/settings.php the following code:

if( \IPS\Member::loggedIn()->isAdmin() )
{
  $data = array();
  $table = new \IPS\Helpers\Table\Custom( $data, \IPS\Http\Url::internal( 'app=core&module=system&controller=settings&area=password' ));
  $table->langPrefix = 'bot_sessions_';
  $table->include = array( 'start', 'end', 'total_time', 'product', 'ip_address' );
  $table->mainColumn = 'ip_address';
  $table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'table' );
  $table->rowsTemplate  = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'rows' );
  return \IPS\Theme::i()->getTemplate( 'panel', 'botuserpanel', 'front' )->sessions((string) $table);

  //return \IPS\Theme::i()->getTemplate( 'system' )->settingsPassword();
}

2. Create a template which outputs the table as HTML and adapt the location in the return statement (step 1) accordingly:

<ips:template parameters="$pastSessionsTable" />
<h2 class='ipsType_sectionHead'>Past Sessions</h2>
<hr class='ipsHr'><br>
<div class='ipsType_normal'>
    {$pastSessionsTable|raw}
</div>

 

Link to comment
Share on other sites

10 minutes ago, inkredible said:

In my oppinion this is a bug, I have inserted my code into core/modules/front/system/settings.php (which also uses the tabsystem) and the problem is exactly the same there. Below the code inserts to reproduce the problem:

applications/core/dev/js/global/controllers/core/ips.core.table.js

			// Check the required elements are in the page
			if( !rows.length || !pagination.length ){
				window.location = this._baseURL + this._getURL();
				return;
			}

It's looks like a bug.

Steps to reproduce

Go to Members page on ACP

The total members should be less then 26 (1 page without pagination)

Try to find member. The page will be reloaded every time when you type a symbol

Example with topics https://invisionpower.com/forums/forum/507-alpha-and-beta-releases/ (1 page without pagination). Use Sort by

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...