Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
JavaScript
$(document).ready(function () {
          $('#btnTest').click(function () {
              try {
                  $.myCustomMethod('testing title!', 'popup.aspx', 600, 400);
              } catch (e) {
                  alert(e);
              }
          });
      });

my js code is

JavaScript
(function ($) { 
$.fn.myCustomMethod = function (title, src, width, height) {
 // all my code here }; 
})(jQuery);


any help would be greatly appreciated.
Posted

1 solution

XML
<div>
<input type="button" id='btnSun' text="Clickme"/>
<div id ='aaa'>hey</div>
</div​>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​


C#
$(document).ready(function() {
  $('#btnSun').click(myFunction);
  $('#aaa').hide();
});
function myFunction() {
  $('#aaa').show();
}



Please Mark as ANSWER if this solution helped u
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900