I am trying to customize link.js plugin to generate dynamic items for select element. But i am facing with problems,
children: [{
id: "pages",
type: "select",
items: pageItems(),
I write a function to generate items for select element and assign it (items: pageItems(),)
The function is;
function pageItems() {
var pageArray = [];
var obj = {};
$("#pageItems li").each(function () {
/*alert($(this).text());*/
var obj = {};
obj[$(this).text()] = $(this).text();
pageArray.push(obj);
});
var JSONText = JSON.stringify(pageArray, null);
JSONText = JSONText.replace(/{/g, "[");
JSONText = JSONText.replace(/}/g, "]");
JSONText = JSONText.replace(/:/g, ",");
alert(JSONText);
return pageArray;
}
First i return directly pageArray but in select all options are undefined. After i serialize pageArray to JSON array but this time a get diffrent problems;
The JSON array is look like;
[["/main/23/hakkimizda","/main/23/hakkimizda"],["/main/24/iletisim","/main/24/iletisim"]]
and the select result is;
please look at the attachment
plz help