Error: no such method 'setDate' for datepicker widget instance
Error: no such method 'setDate' for datepicker widget instance
luisrortega
Posts: 79Questions: 6Answers: 1
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]
[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]
This discussion has been closed.
Replies
Also you could type entering: `$.fn.datepicker` in your browser's console and seeing what you get when you hit return.
Many thanks,
Allan
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,
$.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;
}
[code]
"set": function ( conf, val ) {
conf._input.datepicker( "setDate" , val );
},
[/code]
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
Tks