Jump to content
Mr. NiceGuy

Hooking panel.js close and update MarkupAdminDataTable

Recommended Posts

I am developing a custom Backendmodule where submissions can be managed. 

I am using MarkupAdminDataTable to display the pages with Edit button, then upon click a custom page opens in a panel and then the parent of the page is modified. 

The page should then disappear from the table, so I wanted to reload the table with ajax. 

$out  = "<div id='all_sub'>";
$table = $this->modules->get("MarkupAdminDataTable");
$table->setEncodeEntities(false);
$table->id = 'submissionstable';
$table->headerRow(array(
				$this->_('Name'),
				$this->_('Mail'),
				$this->_('Title'),
				$this->_('Submission date'),
				$this->_('Actions')));

$drafts = $this->pages->find('template=talk|poster,parent="/contributions/saved/",limit=10,sort=-created');

foreach($drafts as $draft) {

				$button = $this->modules->get('InputfieldButton');
				$button->value = 'Approve';
				$button->attr('data-href', './edit/?id='.$draft->id);
				$button->addClass('pw-panel');

				 $table->row(array(
					 $draft->speaker->name => "edit/?id={$draft->id}",
					 $draft->speaker->email,
					 $draft->title,
					 date($this->config->dateFormat,$draft->created),
					 $button->render()
				));
			}
			$out .= $table->render();
			$pager = $drafts->getTotal() > count($drafts) ? $drafts->renderPager() : '';
			$out .= $pager;
}
  $out .="</div>";

When I implement a function like the one described in @bernhard great tutorial on custom backend pages however the panels don't open anymore. 

Precisely they stop opening after the first poll. I couldn't find any state specific variables on the markuptable. Did I miss one ?

$out .='<script>
		$(document).ready(function() {
			function poll() {
			  $.get("./ #all_sub", function(data) {
				$("#all_sub").replaceWith(data);
				
		   });
			}
			setTimeout(poll, 10000);
		  });
  </script>';

 

 

What is the best way to update my markuptable after the panel is closed?

Share this post


Link to post
Share on other sites

Thanks bernhard!  

For reference i did this: 

	$(document).ready(function() {
			function poll() {
			  $.get("./ #all_sub", function(data) {
				$("#all_sub").replaceWith(data);
				pwPanels.init();
		   });
			}
			setTimeout(poll, 15000);
		  });

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...