I'm developing a component,

controllers
    theatercontroller
    facilitycontroller
Models
    theater
    facility
view
    theater
    facility

Things I want is I wish to give a new facility in the theater view by clicking a control button and opening a modal window. I've attempted but did not work. I analyzed some components but it's hard for someone much like me to know it. Please I want an easy example along with a explanation to know it.

This can be used function to obtain a modal button

static public function getModalButtonObject($name,$text,$link,$width=750,$height=480)
{
    JHTML::_('behavior.modal', "a.{$name}");  // load the modal behavior for the name u given
        $buttonMap = new JObject();   // create an Jobject which will contain some data, it is similar like stdClass object
        $buttonMap->set('modal', true);
        $buttonMap->set('text', $text );
        $buttonMap->set('name', 'image');
        $buttonMap->set('modalname', $name);
        $buttonMap->set('options', "{handler: 'iframe', size: {x: ".$width.", y: ".$height."}}");
        $buttonMap->set('link', $link);
        return $buttonMap;
}

And HTML could be written as

<a id="<?php echo $buttonMap->modalname; ?>" class="<?php echo $buttonMap->modalname; ?>" title="<?php echo $buttonMap->text; ?>" href="<?php echo $buttonMap->link; ?>" rel="<?php echo $buttonMap->options; ?>"><?php echo $buttonMap->text; ?></a>

It does not need to be anywhere near that complicated. Many templates turn the modal behavior on already, but when they do not all that you should do is add this towards the mind -

<?php JHTML::_('behavior.modal'); ?>

Adding this to the links you need to open inside a modal window -

class="modal"

Anything else is optional.