2008年12月2日星期二

Re: [fw-mvc] Help Dojo tabContainer

-- barry hembree <gbhembree@comcast.net> wrote
(on Tuesday, 02 December 2008, 07:25 AM -0800):
> I don't know if this is a Dojo question or a ZF question or both. I have a
> page with some tabContainers. One of them is to display an account page. It
> is defined as follows:
>
> <? $this->contentPane()->captureStart('account', array('title' => 'My
> Account',
> 'preload' => false,
> 'href' => $this->url(
> array(
> 'controller'=>'account',
> 'action'=>'index')
> ),
> 'class' => 'account-tab')) ?>
>
> <?= $this->contentPane()->captureEnd('account') ?>

Since you're defining a ContentPane that will be remoting, there's no
reason to use capturing here; just echo it out. Modify the above to:

<?= $this->contentPane(
'account',
'',
array(
'title' => 'My Account',
'preload' => false,
'href' => $this->url(array(
'controller' =>'account',
'action' =>'index'
)),
'class' => 'account-tab'
)
) ?>

> When I select this tab I acces the indexAction of the Account controller. If
> the user is logged in, I display their account summary in this tab. If they
> are not logged in I want to display a login page but not in the
> tabContainer. I would like to re-paint the page with a different layout.
> I've tried several diiferent things but none of them work. Does anyone have
> any ideas?

This *is* more of a Dojo than a ZF question. :)

In your tab payload, I'd suggest adding something like this:

<script type="dojo/event" event="onload">
foo.showLoginDialog();
</script?

Then, in the JS you load for the original page, define a
foo.showLoginDialog() function (I namespaced with "foo" -- you can drop
the namespace, or use something more descriptive to your project). That
function should create a dijit.Dialog that presents the login form. This
is probably the easiest way to achieve what you want. Another
possibility is to use BorderContainer for your application layout, and
tell the main ContentPane to load from a new URL, which is also a very
simple solution.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: