Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I have created a custom jQuery function in my web application and it is working fine without master pages, now I have a master page and i have added a reference to my .js file on the Content page and call the custom js method then it gives me error like
 
Type error: object function (selector, context){ //the jquery object is actually just the constructor 'enhanced' return new jQuery.fn.init(selector, context, rootjQuery); }has no method 'myCustomMethod'
i am calling the custom method like:
  $(document).ready(function () {
            $('#btnTest').click(function () { 
                try {
                    $.myCustomMethod('testing title!', 'popup.aspx', 600, 400);
                } catch (e) {
                    alert(e);
                }
            });
        });
my js code is
 
(function ($) { 
$.fn.myCustomMethod = function (title, src, width, height) {
 // all my code here }; 
})(jQuery);
 
any help would be greatly appreciated.
Posted 9-Sep-12 19:51pm
tanweer13.7K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

<div>
<input type="button" id='btnSun' text="Clickme"/>
<div id ='aaa'>hey</div>
</div​>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
 
$(document).ready(function() {
  $('#btnSun').click(myFunction);
  $('#aaa').hide();
});
function myFunction() {
  $('#aaa').show();
}
 

Please Mark as ANSWER if this solution helped u
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141022.1 | Last Updated 13 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100