Tuesday, April 14, 2009

$(document).ready()

Traditionally Javascript events were attached to a document using an “onload” attribute in the tag of the page.

The $(document).ready() function takes a function as its argument. (In this case, an anonymous function is created inline—a technique that is used throughout the jQuery documentation.)

Understanding Selectors: the Backbone of jQuery

$(document);
The first option will apply the jQuery library methods to a DOM object (in this case, the document object).
$(’#mydiv’)
The second option will select every <div> that has the <id> attribute set to “mydiv”.
$(’p.first’)
The third option will select all of the <p> tags with the class of “first”.
$(’p[title="Hello"]‘)
This option will select from the page all <p> tags that have a title of “Hello”. Techniques like this enable the use of much more semantically correct (X)HTML markup, while still facilitating the DOM scripting required to create complex interactions.
$(’p[title^="H"]‘)
This enables the selection of all of the <p> tags on the page that have a title that starts with the letter H.

Try simple JQuery/javascript online

http://www.w3schools.com/JS/tryit.asp?filename=tryjs_text
Jquey reference online
<html>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript">
document.write("Hello World!");
$(
function()
{
alert('hi');
}
)
</script>

</body>
</html>

Thursday, April 9, 2009

onload event in JQuery

<script type="text/javascript">
$(function() {
alert("This is equal to Form_Load in JQuery");
});
</script>

If getJSON in JQuery can not find exact signature method in Controller, it fails silently.... (ASP.NET MVC)

it fails silently....
Microsoft should put a couple of exclaimation marrk for this documentation somewherem, so we can see to save us sometime!!!!!!!!!!!!!!!!!!!!!!!!!

Example:
If you call getJSON in client side:
$.getJSON('/Home/GetList', { id: $("#country").val() },
You have to create an action in controller in following:
public JsonResult GetList(string id)
{
return Json(test.ToList());
}

But if you:
public JsonResult GetList(int id)
{
return Json(test.ToList());
}

You got nothing!!!!!!!!!!!!!!!!