Closed wnda closed 7 years ago
generate ID on the fly or just use something unlikely to be used?
On the fly would probably be best. It'll complicate the HTML injection but not by much. Only needs to be done once.
k. i'll get working on it.
Great. Let me know how you get on.
I'm thinking something like this:
var j = 0;
var _UI = {
'search': '',
'button': '',
'close': ''
};
for (; Object.keys(_UI).length > j; ++j) {
_UI[Object.keys(_UI)[j]] = generateID(j);
}
function generateID(idx) {
return ('jsrch_' + idx + '_') + (new Date().getTime());
}
// see results: console.log(_UI);
// use like so: [...] '<button id="' + _UI.search + '">'; [...]
oops, sorry i hadn't even started yet!
No worries, I just knew how it could be done so I went ahead and did it myself.
The thought occurs that IDs like 'search', 'searchbutton' etc are apt to cause conflicts with existing websites elements.
While any user of the library will presumably not have any search elements to conflict with, it makes testing on seoscribe.net a little bit messy.