How can I create a jQuery function like
$.MyFunction(/*optional parameter*/)?
which will return a bool?
note:
I've tried this:
jQuery.fn.isValidRequest = function (options) {
return true;
}
// I'm contending with Prototype, so I have to use this
jQuery(document).ready(function ($) {
// and jQuery 1.2.6, supplied by the client - long story
$('a').livequery('click', function () {
alert($.isValidRequest("blah"));
return false;
});
});
but it crashes on the alert() with
Microsoft JScript runtime error: Object doesn't support this property or method
This is what worked in the end:
jQuery.isValidRequest = function (options) {
return true;
}
$.fn, Then you'll need to call it there$.fn.isValidRequest("blah")or from a jQuery object$('selector').isValidRequest(). Doesn't seem like that's what you want. If it is just more of a utility, then define it underjQueryas injQuery.isValidRequest = function(....livequeryinstead oflive(). I could be wrong, though.