jquery custom plugin in joomla is not working

Aleksandra Chuprova

I'm trying to add a custom jquery plugin. But I get the error jQuery(...).termifier is not a function.... I'm pretty sure that there are no mistakes in code

For just test I have tried to copy the code from learn.jquery.com

(function($) {
    $.fn.greenify = function() {
        this.css("color", "green");
        return this;
    };
}(jQuery));

and then

jQuery('..').greenify();

which returns me error jQuery('..').greenify is not a function

What is going on??? Does anyone know the reason of that?

EDIT

the more code. This greenify thing was just to show that it is not working on the standard example....

the actual plugin... It is placed currently just in the same file where later it is called on ellements, so no problem with file not found..

 (function($) {
  $.fn.termifier = function(options) {
   options = $.extend({
      lookupResource: 'getTerm',
     flyoutClass: 'lookerUpperFlyout'
  },options||{});

   this.attr('title','Click me for my definition!');

   return this.click(function(event){
    $.ajax({
       url: options.lookupResource,
       type: 'get',
       data: {term: this.innerHTML},
       dataType: 'html',
    success: function(data) {
      $('<div></div>')
        .css({
          position: 'absolute',
          left: event.pageX,
          top: event.pageY,
          cursor: 'pointer',
          display: 'none'
        })
        .html(data)
        .addClass(options.flyoutClass)
        .click(function(){
          $(this).fadeOut(1500,function(){$(this).remove();});
         })
        .appendTo('body')
        .fadeIn();
      }

    });
    return false;
  });
 };
  }(jQuery));


 jQuery(document).ready(function(){
 ...
 jQuery('abbr').termifier({
    lookupResource: 'some.php'
  });

 });

I'm pretty clueless...

Lodder

Firstly, ensure you're importing jQuery using Joomla's API, like so:

<?php
   JHtml::_('jquery.framework');
?>

This will ensure only 1 instance of jQuery is imported, and in noConflict mode too.

Once done, you should use the jQuery global scope and $ as an alias (optional):

jQuery(document).ready(function($){
    $.fn.greenify = function() {
        this.css("color", "green");
        return this;
    };
});

Hope this helps

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery plugin not working in Joomla 3 module

From Dev

Custom validate method not working - jQuery validate plugin

From Dev

JQuery not working on Joomla 3

From Dev

Create custom plugin joomla with custom ordering on install

From Dev

Joomla Facebook plugin using onContentAfterSave trigger not working

From Dev

Joomla 2.5 Content Plugin Custom Form not shown

From Dev

Call Custom function in joomla plugin by url.

From Dev

combining custom error placement with success is not working jquery validate plugin

From Dev

jquery plugin - how to make $(this) working in the context of a custom setting

From Dev

On document ready get cities by country id not working [ jquery custom plugin ]

From Dev

Custom JavaScript not working in Joomla 3 template

From Dev

jquery slidetoggle() not working in Joomla but works when not using Joomla

From Dev

Chaining not working on jQuery Plugin

From Dev

jQuery colorbox plugin not working

From Dev

Jquery tablesorter plugin is not working

From Dev

Simple jQuery plugin not working

From Dev

Jquery countdownTimer Plugin not working

From Dev

jQuery custom event plugin

From Dev

jQuery custom event plugin

From Dev

jQuery custom plugin

From Dev

Custom jQuery plugin

From Dev

Custom Plugin, in Custom Directory for TinyMCE jQuery plugin

From Dev

Links Selection Not Working in Using jQuery in Joomla Module

From Dev

Add custom Jquery file to joomla 3

From Dev

CKeditor custom plugin allowedContent not working

From Dev

Ajax call Not Working in Custom plugin

From Dev

Joomla 3 replace text plugin using preg replace not working

From Dev

jQuery UI not working in WordPress plugin

From Dev

Regex not working in jquery validation plugin

Related Related

HotTag

Archive