Question

the data is as complex as:

var data = {
    name: 'name',
    info:{
        info1: 'uvbiuonns',
        info2: 'aisbsiece',
    }
}

this would prevent having to get the data from the server on the popup

Was it helpful?

Solution

var data = {
    name: 'name',
    info:{
        info1: 'uvbiuonns',
        info2: 'aisbsiece',
    }
}

var qs = function(obj, prefix){
  var str = [];
  for (var p in obj) {
    var k = prefix ? prefix + "[" + p + "]" : p, 
        v = obj[k];
    str.push(angular.isObject(v) ? qs(v, k) : (k) + "=" + encodeURIComponent(v));
  }
  return str.join("&");
}

window.open("popup.html/?" + decodeURIComponent(qs(data)), "winName", "width=200, height=100");

Also the jQuery one will do:

window.open("popup.html/?" + decodeURIComponent($.param(data)), "MsgWindow", "width=200, height=100");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top