How to add your favorite jQuery UI plugin as a Raxan widget

Imagine you have found the latest jQuery DatePicker that has all of the latest bells & whistles (like the one created by Keith Wood at http://keith-wood.name/datepick.html). Like most jQuery plugins, it comes with the jquery plugin (.js) file, a css file, and an example html file. So, how do you quickly add this to Raxan as a reusable widget? Simple.

Step 1: Copy the jQuery plugin file(s) to the raxan ui/javascripts directory

Step 2: Copy the plugin's css file(s) to the raxan ui/css directory

Step 3: Create the Raxan widget class file

<?php

    class DatePickerWidget extends RaxanUIWidget {

        protected function _init() {
            // load the stylesheet jquery.datepick.css
            $this->page->loadCSS('jquery.datepick');
            // load the javascript
            $this->page->loadScript('jquery.datepick');
            // Bind the datepicker to the element
            // Note that elmID is created in the RaxanUIWidget constructor so it is
            // available here as the jQuery selector
            c('#'.$this->elmId)->datepick();
        }
    }

?> 

Step 4: Load the new DatePickerwidget in your page controller class

<?php
    require_once 'raxan/pdi/autostart.php';
    Raxan::loadWidget('datepickerwidget');

    class IndexPage extends RaxanWebPage {

        protected function _config() {
            $this->masterTemplate ='views/master.html';
        }

        protected function _init() {
            $this->appendView('mypage.html');
        }
    }

?>

Step 5: Start using your new DatePickerWidget in your views

<div class="container">
     <form id="addEmployee" method="post">
        <p>
            <label class="rax-light-title" for="employeeName">Employee Name</label>  
            <input id="employeeName" class="textbox c26 round" />
        </p>
        <p>
            <label class="rax-light-title" for="employeeBirthDate">
            Employee Birth Date</label>
            <br/><input id="employeeBirthDate" 
            class="textbox c17 round" xt-ui="DatePickerWidget" />
        </p>
        <p>
            <input id="cmdAdd" type="submit" class="left button rtm " 
            value="Add Employee" xt-bind="#click,saveEmployee,,true" />       
        </p>
    </form>
</div>

Now, when you want to use the DatePickerWidget on any page, all you have to do is call Raxan::loadWidget('datepickerwidget') in the page controller, and add the xt-ui="DatePickerWidget" on the elements that are used to get dates. Really nice!

Ricky Stanuszek
Posts: 824
Comment
Ricky Stanuszek
Reply #771 on : Sat November 15, 2014, 03:51:17
But he's tryiong none the less.</br><a href="http://www.beveragebuggy.com
">Ricky Stanuszek</a></br>[url=http://www.beveragebuggy.com
]Ricky Stanuszek[/url]</br>http://www.beveragebuggy.com
Ricky Stanuszek
Posts: 824
Comment
Ricky Stanuszek
Reply #770 on : Sat November 15, 2014, 04:58:04
Hello there, I discovered your website by the use of Google whilst looking for a similar subject, your site got here up, it looks great.</br><a href="http://www.beveragebuggy.com

">Ricky Stanuszek</a></br>[url=http://www.beveragebuggy.com

]Ricky Stanuszek[/url]</br>http://www.beveragebuggy.com
Ricky Stanuszek
Posts: 824
Comment
Ricky Stanuszek
Reply #769 on : Sat November 15, 2014, 06:03:13
I've been surfing online more than 4 hours today, yet I never found any interesting article like yours.</br><a href="http://www.beveragebuggy.com


">Ricky Stanuszek</a></br>[url=http://www.beveragebuggy.com


]Ricky Stanuszek[/url]</br>http://www.beveragebuggy.com
Enriqueta Coltey
Posts: 824
Comment
Enriqueta Coltey
Reply #768 on : Sat November 15, 2014, 13:54:54
I am extremely inspired together with your writing talents as {smartly as} with the format in your blog.</br><a href="http://www.metropolitanexpo.com
">Enriqueta Coltey</a></br>[url=http://www.metropolitanexpo.com
]Enriqueta Coltey[/url]</br>http://www.metropolitanexpo.com
Enriqueta Coltey
Posts: 824
Comment
Enriqueta Coltey
Reply #767 on : Sat November 15, 2014, 13:58:09
I am extremely inspired together with your writing talents as {smartly as} with the format in your blog.</br><a href="http://www.metropolitanexpo.com
">Enriqueta Coltey</a></br>[url=http://www.metropolitanexpo.com
]Enriqueta Coltey[/url]</br>http://www.metropolitanexpo.com
Enriqueta Coltey
Posts: 824
Comment
Enriqueta Coltey
Reply #766 on : Sat November 15, 2014, 13:59:05
I am extremely inspired together with your writing talents as {smartly as} with the format in your blog.</br><a href="http://www.metropolitanexpo.com
">Enriqueta Coltey</a></br>[url=http://www.metropolitanexpo.com
]Enriqueta Coltey[/url]</br>http://www.metropolitanexpo.com
Mark Takaoka
Posts: 824
Comment
Mark Takaoka
Reply #765 on : Mon November 17, 2014, 04:37:58
I like what you guys tend to be up too.</br><a href="http://www.directoryfunds.com
">Mark Takaoka</a></br>[url=http://www.directoryfunds.com
]Mark Takaoka[/url]</br>http://www.directoryfunds.com
Mark Takaoka
Posts: 824
Comment
Mark Takaoka
Reply #764 on : Mon November 17, 2014, 05:51:05
I've read this post and if I may just I wish to counsel you some fascinating things or tips.</br><a href="http://www.directoryfunds.com

">Mark Takaoka</a></br>[url=http://www.directoryfunds.com

]Mark Takaoka[/url]</br>http://www.directoryfunds.com
Mark Takaoka
Posts: 824
Comment
Mark Takaoka
Reply #763 on : Mon November 17, 2014, 05:52:24
I've read this post and if I may just I wish to counsel you some fascinating things or tips.</br><a href="http://www.directoryfunds.com

">Mark Takaoka</a></br>[url=http://www.directoryfunds.com

]Mark Takaoka[/url]</br>http://www.directoryfunds.com
Mark Takaoka
Posts: 824
Comment
Mark Takaoka
Reply #762 on : Mon November 17, 2014, 07:06:57
create this web site yourself?</br><a href="http://www.directoryfunds.com


">Mark Takaoka</a></br>[url=http://www.directoryfunds.com


]Mark Takaoka[/url]</br>http://www.directoryfunds.com
First | Previous | Showing comments 11 to 20 of 781 | Next | Last

Leave a Comment

Required fields are marked with *.
If you have trouble reading the code, click on the code itself to generate a new random code.