javascript - Break out of an if statement -


jshint telling me not use label on if statement (it seems labels loops far jshint concerned).

forminjection: if (options.addtoform !== false) {   if (!(options.addtoform instanceof jquery)) {     options.addtoform = $(element).closest("form");     if (options.addtoform.length === 0)     {       options.addtoform = false;       break forminjection;     }   }   $(element).each(function(index){     //do stuff   }); } 

so i'm getting warning on first line above (naturally) on break line.

update: code works intended not right way achieve end result. how should refactored?

okay, i'm testing cleaned solution

if (options.addtoform instanceof jquery || options.addtoform === true) {   if (options.addtoform === true) {     options.addtoform = $(element).closest("form");   }   if (options.addtoform.length === 0) {     // no form found     options.addtoform = false;   } } if (options.addtoform !== false) {   $(element).each(function(index) {     // stuff   }); } 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -