rguliev / conditionize2.js

jQuery plugin for conditioning things
https://rguliev.github.io/conditionize2.js/demo/index.html
MIT License
22 stars 6 forks source link

Maximum Call Stack size exceeded #8

Closed hemant17 closed 3 years ago

hemant17 commented 3 years ago

Uncaught RangeError : Maximum Call Stack size exceeded

when i add much more condition in one place like tis

(varitey  == "CO" && (order_type == "MARKET" || order_type == "LIMIT")) ||  (varitey  == "CO" && (order_type == "SLM" || order_type == "SLL" ) ) || (varitey  == "BO" && order_type) || ( (auto_mation  == "BOT" || auto_mation  == "COT" ) && order_type == "MARKET" ) || ((auto_mation  == "BOT" )&& order_type == "LIMIT") || ((auto_mation  == "COT" )&& order_type == "LIMIT")
rguliev commented 3 years ago

Well, I would not use such a long condition anyway. Why do not you use a function for it?

hemant17 commented 3 years ago

can you please explain ? or example how I do that?

rguliev commented 3 years ago

I mean you can make a condition like: data-condition="myFunction(variety, order_type, auto_mation)" and then in some other place (before calling conditionize()) define your function like:

function myFunction(variety, order_type, auto_mation) {
  return (varitey  == "CO" && (order_type == "MARKET" || order_type == "LIMIT")) ||  (varitey  == "CO" && (order_type == "SLM" || order_type == "SLL" ) ) || (varitey  == "BO" && order_type) || ( (auto_mation  == "BOT" || auto_mation  == "COT" ) && order_type == "MARKET" ) || ((auto_mation  == "BOT" )&& order_type == "LIMIT") || ((auto_mation  == "COT" )&& order_type == "LIMIT")
}
$(".my-conditional-element").conditionize();