You could try to test for the existence of a global function that way, but
it wouldn't work. It would give you a reference error on 'functionname' if
it isn't defined.
 
For a global function you would use:
 
    if( window.functionname ) {
        ...
    }
 
But Miguel's question wasn't about global functions, it was about the
tinymce plugin. He wants to find out if the $(...).tinymce() method exists
before calling it. Since jQuery plugin methods are properties of $.prototype
(aka $.fn), this will work:
 
    if( $.fn.tinymce ) {
        $(...).tinymce({
            ...
        });
    }
 
-Mike



  _____  

From: Michael Lawson

if(functioname)
{
//it exists, do stuff
}
cheers

Michael Lawson
Development Lead, Global Solutions, ibm.com
Phone: 1-276-206-8393 
E-mail: mjlaw...@us.ibm.com 

'Whether one believes in a religion or not,
and whether one believes in rebirth or not,
there isn't anyone who doesn't appreciate kindness and compassion..' 

Inactive hide details for shapper ---09/02/2009 11:28:17 AM---Hello,shapper
---09/02/2009 11:28:17 AM---Hello,




From:    
shapper <mdmo...@gmail.com>     

To:      
"jQuery (English)" <jquery-en@googlegroups.com> 

Date:    
09/02/2009 11:28 AM     

Subject:         
[jQuery] Check if function exists       
  _____  





Hello,

I am loading TinyMCE using the new JQuery Plugin:

<script type="text/javascript">
 $().ready(function() {
    $('textarea.tinymce').tinymce({
      // Location of TinyMCE script
        script_url : '../js/tinymce/jscripts/tiny_mce/tiny_mce.js',

Is there a way to load only if tinymce plugin is present without
getting an error?

Basically if I don't want to load the tinymce I just don't load the
plugin ...
... Because I am not able to pass, I think, to my SiteScript.JS file
if I want to load or not the plugin.

Thanks,
Miguel




<<graycol.gif>>

<<ecblank.gif>>

Reply via email to