This example shows an simple application built using the Layout Mananger, Calendar Control, Rich Text Editor and Connection Manager.
First we must create the panel instance, like this:
Now let's give it some content. Note that we are adding a DIV to the body with an id of layout
. This will be the element we anchor the layout to.
Now we need to listen for the beforeRender
event to render our Layout.
Inside of the beforeRender
event, we will wait for the element layout
to appear in the document, then we will setup our Layout instance.
The layout instance we are creating will have top, left, bottom and center units configured below:
After we have rendered our panel, we can attach the Resize Utility to it like this:
Now give the resize handle a little CSS to make it look nicer.
This will place a handle at the bottom right corner of the panel. This will only resize the outside portion of the panel, but we want the inside to resize properly.
Now we need to listen for the resize
event on the Resize instance and do a little math.
Now we have the Panel resizing the way we want, but the layout is not resizing to match. Inside the resize
event from the Resize instance we need to add this at the bottom:
Now we have a resizable panel with a fixed layout inside.
Now we listen for the layout's render
event and setup our Calendar.
Inside the render
event we will call the layout method getUnitByPosition('left')
to
get the left unit's instance. Then we will create an empty DIV and append it to the body element of the left unit.
Then we will pass that element as the root node for the Calendar Control and render it.
Using the same technique as above, we will add a Rich Text Editor to the center unit.
Using the layout's getUnitByPosition('center')
method, we will set the body of the unit to the textarea
that we will convert into an Simple Editor instance. We will also set a custom toolbar to limit the number of buttons.
Now we need to add some code to the resize
event to resize the Editor instance when the Layout and Panel are resized.
Now we need to connect the Calendar selectEvent
to the Layout Manager.
Now the top unit's header will be updated with the selected date of the Calendar and the Editor will be enabled.
From here, we will set up some pseudo code for saving and storing the data entered on each date selection.
Basically the code below does the following:
dateSelected
to the date.editorData
contains a key matching this date, update the Editor's content with the value.dateSelected
was already set, do this:
html
editorData
for the date and assign its value to the html from the Editor.You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.
Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings