Error: no such method 'setDate' for datepicker widget instance

Error: no such method 'setDate' for datepicker widget instance

luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
edited January 2014 in Editor
First time implementing date out of the Editor... not sure what I'm missing...

[code]










function GetSprints(){
$('#datatable').html( 'Sprints' );

editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "MaintenancePost.php?tbl=5",
"sServerMethod": "POST",
"domTable": "#example",
"fields": [ {
"label": "Name:",
"name": "name"
},
{
"label": "Notes:",
"name": "notes",
"type": "textarea"
},
{
"label": "Expected date:",
"name": "expected_release",
"type": "date",
"dateFormat": 'D, d M y'
},
{
"label": "Actual date:",
"name": "actual_release",
"type": "date",
"dateFormat": 'D, d M y'
}
]
} );

$('#example').dataTable( {
"sDom": "<'row'<'col-xs-2'T><'col-xs-2'f>r>t<'row'<'col-xs-2'i><'col-xs-2'p>>",
"sPaginationType": "bootstrap",
"sAjaxSource": "MaintenancePost.php?tbl=5&",
"aoColumns": [
{ "sTitle": "Name" ,"mData":"name"},
{ "sTitle": "Expected Release" ,"mData":"expected_release"},
{ "sTitle": "Actual Release" ,"mData":"actual_release"}

],
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }]
}//oTableTools
}//constructor parameters
); //constructor...
return false;
}// function

[/code]

Replies

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    That all looks okay and like it should work! Could you possibly post a link to the page you are working on so I can take a look to see what is going wrong?

    Also you could type entering: `$.fn.datepicker` in your browser's console and seeing what you get when you hit return.

    Many thanks,
    Allan
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    >> $.fn.datepicker
    function( options ) {
    var isMethodCall = typeof options === "string",
    args = slice.call( arguments, 1 ),
    returnValue = this;

    // allow multiple hashes to be passed on init
    options = !isMethodCall && args.length ?
    $.widget.extend.apply( null,
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    The site is on early stages in a private network... I might be able to have an external IP early next week...
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    (from Chrome)
    $.fn.datepicker
    function ( options ) {
    var isMethodCall = typeof options === "string",
    args = slice.call( arguments, 1 ),
    returnValue = this;

    // allow multiple hashes to be passed on init
    options = !isMethodCall && args.length ?
    $.widget.extend.apply( null, [ options ].concat(args) ) :
    options;

    if ( isMethodCall ) {
    this.each(function() {
    var methodValue,
    instance = $.data( this, fullName );
    if ( !instance ) {
    return $.error( "cannot call methods on " + name + " prior to initialization; " +
    "attempted to call method '" + options + "'" );
    }
    if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
    return $.error( "no such method '" + options + "' for " + name + " widget instance" );
    }
    methodValue = instance[ options ].apply( instance, args );
    if ( methodValue !== instance && methodValue !== undefined ) {
    returnValue = methodValue && methodValue.jquery ?
    returnValue.pushStack( methodValue.get() ) :
    methodValue;
    return false;
    }
    });
    } else {
    this.each(function() {
    var instance = $.data( this, fullName );
    if ( instance ) {
    instance.option( options || {} )._init();
    } else {
    $.data( this, fullName, new object( options, this ) );
    }
    });
    }

    return returnValue;
    }
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    The error get reported on line 507 of jquery.1.9.1.js... I'm going to remove and re-download jquery... just in case...
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    Aaaaahhhh no need.... the problem seems to be compatibility issues with another jQuery tools (Metro)... after isolating their js (for date time picker), the Editor works show those fields... looks a bit strange, but probably some mess up css...
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    It seems an issue with http://metroui.org.ua/, but I can't figure why? the tools by itself work fine (including the date picker), but together, seems to have an issue... I'm checking their GitHub to see if I find something...
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    notice the error happened when calling (undirectly line 4276 of datatable.editor.js). I'm not sure if setDate is a jquery ui standard and/or if there is a way for me to get around of....

    [code]
    "set": function ( conf, val ) {
    conf._input.datepicker( "setDate" , val );
    },
    [/code]
  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    `setDate` is a standard part of jQuery UI's date picker - http://api.jqueryui.com/datepicker/#method-setDate .

    However, it would appear that MetroUI also creates a jQuery plug-in called `datepicker` ( http://metroui.org.ua/datepicker.html ), which will be replacing the jQuery UI one (whichever is loaded last will "win").

    So there are a few options I think:

    1. Modify MetroUI to attach as a different name (imho they probably should have since jQuery UI is so common).

    2. Create a plug-in for Editor which interfaces with the Metro UI date picker.

    Regards,
    Allan
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    Rename it did the trick! (thou I had to also rename Calendar... and do some css readjustments...) but it works!

    Tks
This discussion has been closed.