$('#list').jqgrid is not a function - jqgrid

I'm trying to use jqgrid and I got this error: $('#list').jqgrid is not a function
My js files are loaded from another url than the one my page is displayed.
Here is my head's js includes:
<script src="http://js.abc.com/js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="http://js.abc.com/js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script>
<script src="http://js.abc.com/js/jqgrid/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="http://js.abc.com/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="http://js.abc.com/js/jquery.layout.js" type="text/javascript"></script>
my js code to load the grid:
<script type="text/javascript">
$(function() {
$('#list').jqgrid({});
});
</script>
When I look at the page source code and click on the js links, the js code is there.
Did I miss something?

$('#list').jqgrid({}); is really wrong. You should use
$('#list').jqGrid({});
(with capital 'G') instead.

Related

Kendo UI error when setting up Date Picker

I am trying to get Kendo Ui (Free Version working). I am trying to implement the date picker with the below code but alls I get is an empty input field. Does anyone have any suggestions on how to resolve this?
<!DOCTYPE html>
<html>
<head>
<link href="/Content/kendo/2015.3.1111/kendo.common.min.css" rel="stylesheet" />
<link href="/Content/kendo/2015.3.1111/kendo.default.min.css" rel="stylesheet" />
</head>
<body>
<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.core.min.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.calendar.min.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.popup.min.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.datepicker.min.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.data.min.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.list.min.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.combobox.min.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.dropdownlist.min.js></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.multiselect.min.js"></script>
<script src="/Scripts/kendo/2015.3.1111/kendo.validator.min.js"></script>
<input id="TimeSlot" name="TimeSlot" type="datetime" />
<script type="text/javascript">
$(document).ready(function () {
debugger;
$("#TimeSlot").kendoDatePicker();
//var datepicker = $("#datepicker").data("kendoDatePicker");
});
</script>
</body>
</html>
You need to reference all these javascript files in order for the DatePicker to work. You can use the Kendo UI Custom Download tool to find out which javascript files you need to reference and to download a custom javascript file that contains everything you need:
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.core.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.calendar.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.popup.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.datepicker.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.data.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.list.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.combobox.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.dropdownlist.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.multiselect.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.validator.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.aspnetmvc.min.js"></script>
UPDATE:
Your text-box's id is "TimeSlot", but in your script you're referring to #datepicker which doesn't even exist. Change your script to this:
<script type="text/javascript">
$(document).ready(function () {
$("#TimeSlot").kendoDatePicker();
//var datepicker = $("#TimeSlot").data("kendoDatePicker");
});
</script>
By the way, you won't need kendo.aspnetmvc.min.js if you don't want to use Kendo's Html Helpers, which is not something that I would recommend if you are using asp.net MVC. With kendo.aspnetmvc.min.js, you wouldn't even need the script, you could just replace your text-box (input tag) with this:
#(Html.Kendo().DatePicker().Name("TimeSlot"))

mootools Scrollable not working

I used mootools scrollable(http://mootools.net/forge/p/scrollable) on my page,but it is not working.
my page: http://neyriz.net/moo/
I used it for div with id="right"
why it's not work?
You are making 2 mistakes. The first is that you try to instanciate the Scrollable before the DOM is ready and so your element doesn't exist. So you have to move your script tag either to the end of the body or you wrap it in an event listener. I.E:
window.addEvent('domready', function() {
var myScrollable = new Scrollable($('right'));
});
The second problem is that the plugin has some dependencies. In this case you need to include Slider, Element.Measure, Element.Shortcuts from MooTools more. You can go to http://mootools.net/more/ and select those 3 modules. Download the file and include it into your head between mootools-core and scrollable:
<script type="text/javascript" src="mootools-core.js"></script>
<script type="text/javascript" src="mootools-more.js"></script> INSERT MOOTOOLS MORE HERE!
<script type="text/javascript" src="scrollable.js"></script>
In general it's better when you define and load your JS files before the body. So it looks like:
<html>
<head><title>My awesome page</title></head>
<body>
<h1>My awesome page</h1>
<p>Some text</p>
<script type="text/javascript" src="mootools-core.js"></script>
<script type="text/javascript" src="mootools-more.js"></script> INSERT MOOTOOLS MORE HERE!
<script type="text/javascript" src="scrollable.js"></script>
</body>
</html>

ASP.NET AJAX.BeginForm sends multiple requests

Im relatevely new with Asp.net MVC3,
I have a form handled with Ajax, like this:
#using (Ajax.BeginForm("dtjson", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "detalle_tarifa", OnSuccess = "exito2", OnBegin="bloquear" }))
My problem is that when I submit data, it sends the request twice.
Lets take a look at the view.
This is the form:
ok, now the view after submit:
And this one is to show firebug debugging:
On the layout, I have those javascript files..
<script src="#Url.Content("~/Scripts/jquery-ui.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.windows-engine.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.jqDock.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.jqDock.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.tablePagination.0.4.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.tools.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.cookie.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.treeview.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.treeview.edit.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
And on the view (A Partial View), I have this:
<script src="#Url.Content("~/Scripts/jquery-1.4.4.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery-ui.js")" type="text/javascript"></script>
<script type="text/javascript" src=#Url.Content("~/Content/tinymce/jscripts/tiny_mce/jquery.tinymce.js")></script>
<script type="text/javascript" src=#Url.Content("~/Content/tinymce/jscripts/tiny_mce/tiny_mce.js")></script>
<script src="#Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="#Href("~/Scripts/jquery.uploadify.js")" type="text/javascript"></script>
<script src="#Href("~/Scripts/jquery.scrollTo.js")" type="text/javascript"></script>
<script src="#Href("~/Scripts/jquery.blockUI.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.min.js")" type="text/javascript"></script>
<script src="/Scripts/jquery.cookie.js" type="text/javascript"></script>
<script src="/Scripts/jquery.treeview.js" type="text/javascript"></script>
<script src="/Scripts/jquery.treeview.edit.js" type="text/javascript"></script>
It seems like it's a problem with jquery... but Im not sure of it...
Any help would be great, Thanks everybody!
You have included jquery.unobtrusive-ajax.min.js twice once in the layout once in the partial. So your browser executes the js inside twice which will subscribe twice on the form click event that is why doing two POST instead of one.
So you need to remove the jquery.unobtrusive-ajax.min.js from the partial.
Note: If your are using a partial with a layout you don't need to duplicate the js included in the partial because it's already done by the layout. There are some good articles about layouts and partials.
You have added jquery.unobtrusive-ajax.js three times. It had happened to me as well.
Check in bundle config "~/ui/js/jquery.unobtrusive.*". the * is wildcard to match both minified or un-minified version. As your solution contains both of the files, it is adding "jquery.unobtrusive-ajax.js" and "jquery.unobtrusive-ajax.min.js". Again in your view page or layout page, you have added jquery.unobtrusive-ajax.js/jquery.unobtrusive-ajax.min.js which is making three times request/post
I my case I had "return View" instead of "return PartialView".

Ajax.BeginForm returns full page

I want to use the Ajax.BeginForm, without updating any element, only call the callback javascript function.
I've attached js libraries
<script src="#Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
I use:
#using (Ajax.BeginForm(new AjaxOptions {OnComplete = "AddPostComplete"}))
{
//some code
}
and
<script type="text/javascript">
$('#asdf').click(function () {
//some code
});
</script>
the js function isn't used, and the page return full view.
With unobtrusive javascript enabled you will also need to include jquery.unobtrusive-ajax.min.js

Using the jQuery plugin ColorBox in noConflict() mode

I am using the jQuery plugin ColorBox in a Joomla! theme, and am having a hard time getting it to work in noConflict() mode. I have the following code that calls my jQuery and the noConflict(); call, followed by my actual jQuery markup:
<script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" language="javascript">jQuery.noConflict();</script>
<script type="text/javascript" language="javascript" src="PATH TO COLORBOX"></script>
<script type="text/javascript" language="javascript">
jQuery(document).ready(function(){
jQuery('a.colorbox').colorbox();
})
</script>
However, I simply cannot get it to work under noConflict() mode. when disabling the no conflict mode it works no worries, but then the associated Mootools scripts in Joomla do not work.
Can someone point me in the right direction here?
Much Appreciated,
Simon
It turned out that after all of this, it was related to the order in which Joomla! was calling scripts. So for all those who stumble across the same issue, your script calls must all be called AFTER Joomla! include head tag, like follows:
<jdoc:include type="head" />
<script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" language="javascript">jQuery.noConflict();</script>
<script type="text/javascript" language="javascript" src="<?php echo JURI::base(); ?>templates/helen-o-grady/js/jquery.colorbox-min.js"></script>
<script type="text/javascript" language="javascript">
jQuery(document).ready(function(){
jQuery('a.colorbox').colorbox({iframe:true, width:900, height:650});
})(jQuery)
</script>
Here is answer: How to use no conflict for two types of jquery scripts.
I have fixed this way:
<script type="text/javascript">
var jQuery1_10_2 = $.noConflict(true);
jQuery1_10_2 (document).ready(function() {
jQuery1_10_2 (".video-popup").colorbox({iframe:true, innerWidth:850, innerHeight:509, fixed:true});
});
</script>
here .video-popup is my popup wrapper class. change it.

Resources