javascript onclick is not working

Using Servoy to administrate the content of your website? Discuss all webrelated Servoy topics on this forum!

javascript onclick is not working

Postby nandlalajisingh » Wed Sep 02, 2015 4:42 pm

Hi All

I encounter another problem. onclick function is not working

var html ='<html lang="en">'
+'<body>'
+ '<div>'
+ '<ul>'
+ '<li><a id ="DashBoard" onclick="runMenuHandler(id)" href="javascript:;" ><span>DashBoard</span></a></li>'
+ '</ul>'
+ '</div>'
+ '<script src="media:///js/jquery.js"></script>'
+ '<script>'
+ '$(document).ready(function() {'

+ 'function runMenuHandler(layoutId){'
+ plugins.WebClientUtils.generateCallbackScript(runMenuHandlerServoy, ['layoutId'])
+ '}'
+ '});'
+ '</script>'

+'</body></html>';

i am doing this onShow function. I did write runMenuHandlerServoy. The thing is that its given good UI. but on click its not hitting function runMenuHandler. console.log inside runMenuHandler is not printing any thing.

onclick="javascript:runMenuHandler(id)" is giving error -
Could not eval the string 'runMenuHandler(id)'
ReferenceError: "runMenuHandler" is not defined. (internal_anon#1)
at internal_anon:1


Though following code is working fine
+'$("#DashBoard").click(function(event){'
+ plugins.WebClientUtils.generateCallbackScript(runMenuHandlerServoy,['event'])
+'});'


Note: i have used some external js like dcjqaccordion.2.7.js, cookie.js etc. though the code is bit complicated, loading the values from database but i have given simple sample. I cant use .click way because with many item in list its difficult to manage. So, onclick would be a better option

Please help. I did many hit and trial but none is giving me proper result.

Thanks
Nand
nandlalajisingh
 
Posts: 15
Joined: Thu Jun 05, 2014 9:14 am

Re: javascript onclick is not working

Postby nandlalajisingh » Thu Sep 03, 2015 3:25 pm

got the solution folk,
Dunno whats with the word. but changing the word from runMenuHandler to some other word is working now. Though i changed the above formate to used CDATA (https://wiki.servoy.com/display/DOCS/Cu ... Web+Client). But again the runMenuHandler word was not working in this formate too.

Any ways if some one knows the answer for this uncertain behaviour. please post it here.
nandlalajisingh
 
Posts: 15
Joined: Thu Jun 05, 2014 9:14 am


Return to Web Development

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest