How can function be defined via "fn" member in Javascript? -


i found following definition

$.fn.flex = function ( options ) {    var p = this.data("flex"),            opts = options || {};    if (p) return p;    this.each(function () {       p = new flex( this, opts );       $(this).data("flex", p);    });    return opts.api ? p : this; };  

which defines function flex() in original code.

unfortunately, stops defining function in environment, i.e. function call causes error flex not function.

what critical here flex being function?

update

sorry, didn't modify anything. put javascript https://github.com/jasonenglish/jquery-flex/ environment (liferay) , code run script

<script type="text/javascript">     $(function() {         $(".flex").flex();     });     </script> 

caused error. replaced $ jquery everywhere did before , still not working.

update 2

hmmm. error occurs in widget.js twitter. says

typeerror: jquery(...).flex not function 

if rename flex flex1 everywhere, says "flex1" not function.

sorry, didn't modify anything. put javascript ... environment (liferay) , code run script

because that's jquery plug-in, need make sure include script after jquery on page. so

<script src="/path/to/jquery.js"></script> <script src="/path/to/the-plugin.js"></script> 

if put them in other order, first script fail because try take value of jquery symbol, doesn't exist yet, throwing referenceerror (in both loose , strict mode).


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -