Skip to content
This repository was archived by the owner on Aug 20, 2022. It is now read-only.

JavaScript UI Methods

benank edited this page Aug 19, 2020 · 3 revisions

While in JavaScript land, we have some methods accessible to us that allow us to communicate back to the client in Lua land.

Keep in mind that the JavaScript here must be included in an HTML file that was created using UI:Create. By doing this, we automatically get these nice methods to use.

OOF.GetFocus(elem)

  • Focuses on a certain element. Great for setting focus on inputs, like textboxes.
  • elem (jQuery element): element that you want to focus on

OOF.CallEvent(event_name, data)

  • Calls an event back to the client side in Lua.
  • To receive this event in Lua, use UIInstance:Subscribe.
  • event_name (string): event name that you want to call
  • data (object or array): data that you want to send with the event

OOF.Subscribe(event_name, callback)

  • Subscribes to an event called from Lua.
  • To call the corresponding event in Lua, use UIInstance:CallEvent.
  • event_name (string): event name that you want to subscribe to
  • callback (function): function that you want to call when the event is triggered
Clone this wiki locally