I have this script in the head
of my index.html. I want different scripts to run when different pages are shown, because I populate the pages programatically. Pages have IDs page1
, page2
etc. Page-specific functions are called page1init()
, page2init()
etc.
document.addEventListener('deviceready', function(){
$("div[data-role=page]").on('pageshow', function(){
eval(this.id + 'init()')
})
$('#page1').trigger('pageshow')
})
Is this reasonable and does using eval()
here introduce security issues?
Since nobody has answered, I suppose I have to default to a 'yes'? Please feel free to edit this/answer if you feel otherwise.