[jQuery] jquery.calculation modification
Hello,
I need some help on jquery.calculation plugin modification (I want to
change it so that it would also read the attributes of elements if a
string is passed as an attribute name).
I want to change the .calc function so that I could optinally pass a
string with each jquery object which are passed as an array of
objects:
("[id^=total_item]").calc(
"qty * price",
// define the variables used in the equation, these can be a jQuery
object
{
qty: $("input[name^=qty_item_]"),
price: $("[id^=price_item_]")
},
function (s){
return "$" + s.toFixed(2);
},
function ($this){
}
);
I want to be able to specify a string for each row in an array (qty,
price) (as an array).
Maybe something like:
qty: $("input[name^=qty_item_]")["some_str"],
price: $("[id^=price_item_]")
I'm unsure how should I change the syntax and retrive the value inside
the calc function (the second argument is called vars):
for( var k in vars ){
// replace the keys in the expression
expr = expr.replace( (new RegExp("(" + k + ")", "g")), "_.$1");
if( !!vars[k] && !!vars[k].jquery ){
parsedVars[k] = vars[k].parseNumber();
} else {
parsedVars[k] = vars[k];
}
}
Many thanks in advance!