Right now, I'm trying this:
[lua]
p:RunJavascript([[
function mypanel() {
//blah
}
mypanel.callbackstuff = function()
alert('test');
}
]])
p:AddFunction("mypanel","callbackstuff",function(param)
if param == nil then print("nil :(") else print(param) end
end)
p:RunJavascript("mypanel.callbackstuff()")
>> nil :(
[/lua]
How can I get this working? Any other methods of causing lua to run clientside from within the javascript of a HTML or DHTML panel are appreciated.
I know with a DHTML panel, you can do
[lua]dhtml:SetAllowLua( true )
dhtml:QueueJavascript( "RUNLUA: MsgN('hi!')" )[/lua]
Though there are vulnerabilities if you use AllowLua with a site loaded from a website.
Not working. Nothing else to say, it just doesn't respond to the lua. Other javascript commands work fine.
Thanks!
Regardless, if anyone knows how to get callbacks working (for the security), I'd really appreciate it.
[QUOTE=Handsome Matt;40713892]That's because it doesn't work that way, you need to use console.log like so:
[code]console.log( 'RUNLUA: print("hello world")' );[/code][/QUOTE]
aww, what. I meant to edit my post. Guess it didn't get through. Sorry about the confusion.
You need to use an object literal for what you're trying to do.
[code]var mypanel = {};
mypanel.callbackstuff = function() {
console.log("hello world");
}[/code]
For more info, read through this: [URL]https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Working_with_Objects[/URL]
Sorry, you need to Log In to post a reply to this thread.