more filter with date picker

edited October 2011 in Modules
I have create a additional filter to show on items listing page, then I want to add a date field with date picker , it seem like I need to load the js param 'add_edit' in order to do that ? but because items page need to load the 'items' js param, it there any way to load the datepicker in this case ?

Comments

  • edited 7:30AM
    I'm not quite sure I understand. Are you wanting to use the datepicker on the list items view instead of the normal form view?
  • edited 7:30AM
    yup, i using the extend module controller method to have my own controller and view for the list items page, but can't find a way to inject the datepicker in.
  • edited 7:30AM
    The javascript that initiates the datepicker is in the fuel/modules/fuel/assets/js/fuel/controller/BaseFuelController.js file and is executed only on the form view. To execute it for your list view, you would need to extract it out and put it into perhaps a separate js file that gets loaded using the module's "js" config parameter. Below is the link the parameters you can pass to a simple module (which i'm guessing you are already familiar with but just in case):
    http://www.getfuelcms.com/user_guide/modules/simple
  • edited 7:30AM
    noted and thanks, will try this.
  • edited 7:30AM
    Hello,

    I want to implement this datepicker http://jqueryui.com/datepicker/ in one of my admin view files

    I have made following changes in fuel/application/views/_blocks/header.php file
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <script>

    my view file is in fuel/modules/exporttocsv/views
    <script> $(function() { $( "#txt_from" ).datepicker(); $( "#txt_date2" ).datepicker(); }); function validate() { var from =$("#txt_from").val(); var to =$("#txt_to").val(); if(!from || !to){ alert('Enter both FROM and TO date'); return false; } else { return true;} } </script> <style type="text/css"> </style> <div id="main_top_panel"> <h2 class="ico ico_blog_settings">Export to CSV </h2> </div> <div class="clear"></div> <div id="notification" class="notification"> <?=$notifications?> </div> <div id="main_content" class="noaction"> <div id="main_content_inner"> <div id="notification_extra" class="notification"> </div> <p class="instructions"> </p> <form action="exporttocsv/abc" method="post" id="frm_date"> From date:<input type="text" id="txt_from" name="txt_from" /><br/><br/> To date:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="txt_to" name="txt_to" /> <br/><br/> <input type="submit" value="Export to CSV" onclick="javascript:return validate();"> </div> </div>

    I am not able to use jquery datepicker, can anybod help?
  • edited 7:30AM
    The header file you made the changes in is for the front end and not the CMS. You can include those JS files and CSS by adding them to the "fuel_javascript" and the "xtra_css" parameters in your MY_fuel.php file:
    $config['fuel_javascript'][] = 'http://code.jquery.com/jquery-1.9.1.js'; $config['fuel_javascript'][] = 'http://code.jquery.com/ui/1.10.2/jquery-ui.js'; $config['xtra_css'] = 'http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css'; Also the 1.0 beta uses the jQuery UI datepicker and has those files already loaded: https://github.com/daylightstudio/FUEL-CMS/tree/1.0
  • edited 7:30AM
    Hello,

    I have included the code in MY_fuel.php file. and i was able to get the jquery datepicker. But i had issue with modules created using Base_module_model. It keeps refreshing. But wont load the list items in list view. I think it is because of the $config['fuel_javascript'][] added in my_fuel.php.

    Is there a way to include the the datepicker related configurations in my controller file itself so that it wont effect other modules.
    <?php require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php'); class Exporttocsv extends Fuel_base_controller { public $view_location = 'generatecsv'; public $nav_selected = 'generatecsv/exporttocsv'; function __construct() { parent::__construct(); $this->config->module_load('generatecsv', 'generatecsv'); } function index() { $this->_render('exporttocsv_tpl', $vars); }
  • edited 7:30AM
    Yes. You can pass a $vars['js'] variable in your render statement like so:
    function index() { $vars['js'] = 'my_js_file.js'; $this->_render('exporttocsv_tpl', $vars); }
    Also, are there any error messages in your browsers console when viewing the list_items page?
  • edited March 2013
    Thank you,that worked!

    items wont appear in list view. It looks like it is keeps refreshing in list view.

    i found this error
    Uncaught TypeError: Object function ( selector, context ) {
    // The jQuery object is actually just the init constructor 'enhanced'
    return new jQuery.fn.init( selector, context, rootjQuery );
    } has no method 'cookie' BaseFuelController.js:94
  • edited 7:30AM
    I'm wondering if this thread may help. That error sounds like it is saying the jQuery cookie plugin isn't loaded:
    http://getfuelcms.com/forums/discussion/comment/1610/#Comment_1610
Sign In or Register to comment.