English 中文(简体)
How to create a "New xxx" popup?
原标题:

I have a Grid object and added a [ (+) New Client ] button which I d like to open a popup form to create the new client with a couple fields.

I ve looked at the code examples in the website but haven t found how to do it (sorry if I ve missed something).

This is the current page code:

function page_clients_listing($p){

    $g = $p->add( Grid );
    $g->addColumn( text , first_name );
    $g->addColumn( text , last_name );
    $g->addColumn( inline , telephone );
    $g->addColumn( expander , comments );
    $g->setSource( client );

    $g->addButton( With Icon )->set( Add New Client )->setIcon( Plus );
}

Thanks in advance!

最佳回答

You can either create a popup or a dialog. Dialog is based on jQuery UI dialog implementation. Popups are likely to be blocked and are harder to control.

This is actually working for any object (you can apply to view, button, image, icon, etc), but I ll use button).

$b=$g->addButton( Add New Client )->setIcon( Plus );

$b->js( click )->univ()->frameURL($title,$url);
// OR
$b->js( click )->univ()->dialogURL($title,$url);

$url would most likely be returned by api->getDestinationURL(). The other page would be loaded and scripts on that page will be evaluated. Let s say you are on other page and now need to close the window.

$result = $this->addButton( Close )->js( click )->univ()->closeDialog();

closeDialog() returns a jQuery chain object pointing to a view which originally opened the frame. As a result if you do $result->hide(); then after dialog is closed, the original button ( add new client ) will also be hidden.

Here is example to show some additional things you can do with frames, reloading and custom event handlers:

http://agiletoolkit.org/example/refresh1

问题回答

暂无回答




相关问题
The proper way to handle popup closing

I m looking for close event for popup. I ve found one for XUL, but I need it for HTML. Popup has closed property. >>> var popup = open( http://example.com/ , popup , height=400,width=500 )...

Javascript OnClick Event - 2 functions

i used a onclick event for this js function: window.opener.location.href =foobar; After loading foobar in the Parent window this window should close. It is a popup (opended with JS)

how to control popup with ruby on rails, mouse roll-over

I have an application where user can see a list of cells. For each cell the user can see two images of the cell as popup menu. The problem is that all images are downloaded when a list is selected and ...

Popping up windows from a SharePoint webpart

I m trying to pop a window up, from inside a procedure running in SharePoint. I need to pass a parameter to the URL, and have been trying to run the following, however, the popup never pops up. ...

WPF DataGrid CellEditingTemplate with floating control

I m using the WPF DataGrid and want to make my own CellEditingTemplate. I want to replicate something like the DatePicker that doesn t replace the whole contents of the cell when its being edited, but ...

Postback after JQuery Dialog box closes causes js error in IE

I am creating JQuery dialog boxes and need the close functionality to cause a postback to the parent form (so that data changed in the popup form displays immediately on the parent screen). I have ...

热门标签