TypeError: $("#datepicker").datepicker is not a function - jquery-ui

Ive read the other questions about this and I know that this is related to date picker not loaded on the page. however I would like to know how to figure out which functions have loaded with JQuery.
The code I'm using is quite basic so I'm not certain why this is failing anyways:
<script type='text/JavaScript' src='jquery.js'></script>
<script type='text/JavaScript' src='jquery.ui.core.js'></script>
<script type='text/JavaScript' src='jquery.ui.widget.js'></script>
<script type='text/JavaScript' src='jquery.ui.datepicker.js'></script>
<script src='jquery.validate.js' type='text/javascript'></script>
<link href='jquery_ui_base\jquery.ui.all.css' rel='stylesheet' type='text/css'>
<script type='text/javascript'>
jQuery(function() {
calender();
});
function calender(){
$( '#datepicker' ).datepicker()
}
</script>

this usually happens when the jquery core and/or the datepicker js is not being loaded.
check if it's loading (a 200 response). Make sure you have the correct paths and proper read permissions.
also, make sure the jquery core is loaded before the datepicker, and that datepicker is loaded before $( '#datepicker' ).datepicker() .
Also, you could try uploading a new version of datepicker.

Related

jQuery-UI datepicker TypeError: o is undefined

I am not able to find out, why this error appears:
TypeError: o is undefined jquery-ui.min.js:9:4005
This is my javascript:
$(document).ready(function() {
$('.inputDate').datepicker({
dateFormat:'dd.mm.yy',
});
});
This is my HTML:
<label class='required'
for='event_start'>Datum</label>
<input id='event_start'
class='inputDate'
name='event_start' readonly
value='22.04.2019'>
The included files in the head of the page:
<link rel="stylesheet" type="text/css" href="js/jquery-ui-1.12.1/jquery-ui.min.css" media="screen"> </link>
<script language="JavaScript" type="text/javascript" src="js/jquery-1.12.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery-ui-1.12.1/jquery-ui.min.js"> </script>
The datepicker widget appears, but nothing happens, after I choose a date. I see the above error message in firefox web developer tools.
I found the reason of the problem:
The HTML element id="event_start" occurred several times in the code.
Jquery uses the id to map the datepicker to the proper input element although a class is defined as selector.

jQuery UI error: TypeError: this._addClass is not a function [duplicate]

I am having an issue getting a dialog to work as basic functionality. Here is my jQuery source imports:
<script type="text/javascript" src="scripts/jquery-1.9.1.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.11.1.js"></script>
<script type="text/javascript" src="scripts/json.debug.js"></script>
Html:
<button id="opener">open the dialog</button>
<div id="dialog1" title="Dialog Title" hidden="hidden">I'm a dialog</div>
<script type="text/javascript">
$("#opener").click(function() {
$("#dialog1").dialog('open');
});
</script>
From the posts around seems like as a library import issue. I downloaded the JQuery UI Core, Widget, Mouse and Position dependencies.
Any Ideas?
Be sure to insert full version of jQuery UI. Also you should init the dialog first:
$(function () {
$( "#dialog1" ).dialog({
autoOpen: false
});
$("#opener").click(function() {
$("#dialog1").dialog('open');
});
});
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" />
<button id="opener">open the dialog</button>
<div id="dialog1" title="Dialog Title" hidden="hidden">I'm a dialog</div>
if some reason two versions of jQuery are loaded (which is not recommended), calling $.noConflict(true) from the second version will return the globally scoped jQuery variables to those of the first version.
Some times it could be issue with older version (or not stable version) of JQuery files
Solution use $.noConflict();
<script src="other_lib.js"></script>
<script src="jquery.js"></script>
<script>
$.noConflict();
jQuery( document ).ready(function( $ ) {
$("#opener").click(function() {
$("#dialog1").dialog('open');
});
});
// Code that uses other library's $ can follow here.
</script>
If you comment out the following code from the _Layout.cshtml page, the modal popup will start working:
</footer>
#*#Scripts.Render("~/bundles/jquery")*#
#RenderSection("scripts", required: false)
</body>
</html>
Change jQueryUI to version 1.11.4 and make sure jQuery is not added twice.
I just experienced this with the line:
$('<div id="editor" />').dialogelfinder({
I got the error "dialogelfinder is not a function" because another component was inserting a call to load an older version of JQuery (1.7.2) after the newer version was loaded.
As soon as I commented out the second load, the error went away.
Here are the complete list of scripts required to get rid of this problem.
(Make sure the file exists at the given file path)
<script src="#Url.Content("~/Scripts/jquery-1.8.2.js")" type="text/javascript">
</script>
<script src="#Url.Content("~/Scripts/jquery-ui-1.8.24.js")" type="text/javascript">
</script>
<script src="#Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript">
</script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript">
</script>
<script src="#Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript">
</script>
and also include the below css link in _Layout.cshtml for a stylish popup.
<link rel="stylesheet" type="text/css" href="../../Content/themes/base/jquery-ui.css" />
I had a similar problem and in my case, the issue was different (I am using Django templates).
The order of JS was incorrect (I know that's the first thing you check but I was almost sure that that was not the case, but it was). The js calling the dialog was called before jqueryUI library was called.
I am using Django, so was inheriting a template and using {{super.block}} to inherit code from the block as well to the template. I had to move {{super.block}} at the end of the block which solved the issue. The js calling the dialog was declared in the Media class in Django's admin.py. I spent more than an hour to figure it out. Hope this helps someone.

Bootstrap-material-design: Install successful, but didn't work

I installed bootstrap-material-design as instructed on the github website and everything said it was installed successfully:
I have inserted the recommended code into my application header:
<!-- Material Design fonts -->
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto:300,400,500,700">
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/icon?family=Material+Icons">
<!-- Bootstrap -->
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- Bootstrap Material Design -->
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap-material-design/dist/css/bootstrap-material-design.css">
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap-material-design/dist/css/ripples.min.css">
<!-- Material Design Scripts -->
<script src="bower_components/bootstrap-material-design/scripts/index.js"> </script>
<script src="bower_components/bootstrap-material-design/scripts/material.js"> </script>
<script src="bower_components/bootstrap-material-design/scripts/ripples.js"> </script>
and
<script type="text/javascript">
$(document).ready(function() {
$.material.init();
});
</script>
However, when I try a sample element (e.g. "jumbotron" or "well") it still appears the way normal bootstrap does, not the way your material design website says it should.
Any ideas on how to get it to appear? I didn't get any error message, so I don't really have anything to go on, and I don't want to manually download the files for fear of duplicates.
Apparently you do not have a reference to the correct JS files. Trying adding these to you code in the head section
<script src="scripts/index.js"> </script>
<script src="scripts/material.js"> </script>
<script src="scripts/ripples.js"> </script>
You seems to be missing references to jQuery and bootstrap's .js file. You should include both before material design script in that order.

Problems with Jira gadget configuration screen

I keep running in to strange issues when writing gadgets for Jira. I get problems like the options being clipped out of view, reconfiguration not working and most annoyingly: projectOrFilterPicker not working.
Most of the weird issues I run in to I can work around which is what I've done however I need to allow the user to use that quick search box for selecting a project or a filter. However, as soon as I include one of these dialog boxes the gadget just loads endlessly and if I resize the screen (one of the workarounds I use for other things) I get an error 500.
A weird thing is that it works locally on the Atlassian SDK test Jira (V 4.4) but not on my workplaces full test server (V 2.1.3).
This is some of the code I'm using and I can post more if necessary:
var projectPicker = AJS.gadget.fields.projectOrFilterPicker(gadget, "projectId", args.projectOptions);
args.projectOptions are defined here:
args: function()
{
return [
{
key: "projectOptions",
ajaxOptions: "/rest/gadget/1.0/filtersAndProjects"
}
];
}()
Any insight/suggestions would be greatly appreciated. Thanks in advance.
Carl
I added the following code to the top of the gadget javascript:
<link type="text/css" rel="stylesheet" href="http://iedev255/s/531/4/1.0/_/download/batch/jira.webresources:autocomplete/jira.webresources:autocomplete.css" media="all">
<link type="text/css" rel="stylesheet" href="http://iedev255/s/531/4/4.1.2/_/download/batch/com.atlassian.jira.gadgets:common/com.atlassian.jira.gadgets:common.css" media="all">
<link type="text/css" rel="stylesheet" href="http://iedev255/s/531/4/4.1.2/_/download/resources/com.atlassian.jira.gadgets:common/global.css" media="all">
<script type="text/javascript" src="http://iedev255/s/531/4/2.1.3/_/download/batch/com.atlassian.auiplugin:ajs/com.atlassian.auiplugin:ajs.js" ></script>
<script type="text/javascript" src="http://iedev255/s/531/4/1.0/_/download/batch/jira.webresources:jira-global/jira.webresources:jira-global.js" ></script>
<script type="text/javascript" src="http://iedev255/s/531/4/1.0/_/download/batch/jira.webresources:autocomplete/jira.webresources:autocomplete.js" ></script>
<script type="text/javascript" src="http://iedev255/s/531/4/4.1.2/_/download/batch/com.atlassian.jira.gadgets:common/com.atlassian.jira.gadgets:common.js" ></script>
It solved a lot of my problems

CKEditor 3.1 jquery adapter?

<script type="text/javascript" language="javascript" src="/Content/Scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/Content/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/Content/ckeditor/adapders/jquery.js"></script>
<script type="text/javascript" language="javascript">
$(function() {
$('textarea.ckeditor').ckeditor();
});
</script>
<textarea class="ckeditor" cols="5" id="Title" name="Title" rows="5">
</textarea>
It all works fine but before loading page it alerts this "Microsoft JScript runtime error: Object doesn't support this property or method"
But it works after the Visual Studio alert, what might be the reason ?
Thanks in advance
You should put the code to create the CKEditor instance after the textarea element (or on the onload event of the page).
I don't think that this is also part of the problem, but the folder as distributed is named "adapters", not "adapders"
And it works later because the textarea has the class="ckeditor", so that textarea is automatically replaced: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.html#.replaceClass

Resources