javascript - First jQuery plugin, am I on the right track? -


So I think it should be very simple ... its just a custom checkbox plugin that takes from div and checks them CSS changes in I really need to do this, basically swaps CSS and triggers events. I just need to do these tasks (init, check, uncheck, toggle, disabled). In any way that I've done so far, but the toggle method and IM on the last part in general .... } {$ (This) .addClass ('cb-unchecked'); $ (this) .click (// to call the toggle method, but uncertain syntax);}, check: function () {return.Each (function ('Cb-check') Trigger ('check', this);})}, uncheck: (function) () {$ (This) .removeClass ('cb- disabled cb- uncheck') Return Adultus ('CB-Czech'). Trigger ('uncheck', this);});}, toggle: function ()) {Return this. Every (function () {var t = $ (this); if (t.hasClass ('cb-checked')) should call {// check function, but I do not know how ...} Else if ( T.hasClass ('cb-unchecked')) {// call uncheck function, but I do not know how ...}}}}, disable: function () {this.each return (function () {$ (This) .removeClass ('CB-checked CB-uncheck'). AddClass ('cb-disabled'). Trigger ('disabled', this);});}}; $ .fn.customCheckbox = Function (verb) {// I have lost on what gets here for a while / if (method [action]) {method [verb] .app Ly (this, argument); } // ??? This return; }}) (JQuery);

Am I going to the right direction or am I going to be totally different about this?

Yes, you are on the right track (function ($) {..}) (jQuery ) To play jquery well with other javascript libraries. You return to this; You can properly extend jQuery by using $ .fn.customCheckbox = ... . Applying the parameters to the function allows you to say your comment. Finally, just call it.

  $ ("input [type = 'checkbox']"). Custom chexbox ('init');   

However, I probably can not convert the init code to $ Body.fn.customCheckbox = function will move {...} to the body when ! Action

  $ .fn.customCheckbox = function (verb) {if (! Action) {// init here} // other logic returns here; }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -