I am using this method in order to convert an Object to QueryString.
QueryString is required for ajax
send request.
var objectToQueryString = function(a) {
var prefix, s, add, name, r20, output;
s = [];
r20 = /%20/g;
add = function(key, value) {
// If value is a function, invoke it and return its value
value = (typeof value == 'function') ? value() : (value == null ? "" : value);
s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
};
if (a instanceof Array) {
for (name in a) {
add(name, a[name]);
}
} else {
for (prefix in a) {
buildParams(prefix, a[prefix], add);
}
}
output = s.join("&").replace(r20, "+");
return output;
};
function buildParams(prefix, obj, add) {
var name, i, l, rbracket;
rbracket = /\[\]$/;
if (obj instanceof Array) {
for (i = 0, l = obj.length; i < l; i++) {
if (rbracket.test(prefix)) {
add(prefix, obj[i]);
} else {
buildParams(prefix + "%" + (typeof obj[i] === "object" ? i : "") + "%", obj[i], add);
}
}
} else if (typeof obj == "object") {
// Serialize object item.
for (name in obj) {
buildParams(prefix + "%" + name + "%", obj[name], add);
}
} else {
// Serialize scalar item.
add(prefix, obj);
}
}
I have a loading object, with boolean values for each loading. My state looks like this: state: { loading: { itemA: false, itemB: false, itemC: false } } I want to update my state ...
I have a loading object, with boolean values for each loading. My state looks like this: state: { loading: { itemA: false, itemB: false, itemC: false } } I want to update my state ...
I create a new record, this record is successfully added to the database. That's good. But the problem is that it doesn't update the list of existing records - means the push function doesn't seems to ...
I create a new record, this record is successfully added to the database. That's good. But the problem is that it doesn't update the list of existing records - means the push function doesn't seems to ...
I am trying to use the map function to create an array of the items returned from a collection. My implementation is using the forEach to iterate which works fine. However, I can't get it to work ...
I am trying to use the map function to create an array of the items returned from a collection. My implementation is using the forEach to iterate which works fine. However, I can't get it to work ...
I have a jQuery plugin that does template transformation, and an Angular directive that integrates with the plugin by calling $compile after the plugin runs on the produced DOM node: //in the link ...
I have a jQuery plugin that does template transformation, and an Angular directive that integrates with the plugin by calling $compile after the plugin runs on the produced DOM node: //in the link ...