Bind (Method)

From Legacy Roblox Wiki
Jump to navigationJump to search
Bind( Instance object, String property, String htmlElementId )
Returns nil
Description: Binds the property of an instance to an HTML input.
Member of: HtmlWindow


Example
This code will create a Hint, and Bind an input to the Text property. It will give the option to toggle the Bind:
html = game:service("HtmlService")

wind = html:NewWindow()
wind:Navigate()

hint = Instance.new("Hint", game.Workspace)
hint.Name = "BindedHint"

function Call(ValueReturn)
	if ValueReturn == "bind" then
		wind:Bind(hint, "Text", "scriptsrc")
	elseif ValueReturn == "unbind" then
		wind:Unbind()
	end
end

wind.DocumentComplete:connect(function(url)
	wind:SetBody([==[
		<input id="scriptsrc">

		<input type="submit" onclick="window.external.Call('bind');" value="Bind Me!">
		<input type="submit" onclick="window.external.Call('unbind');" value="Unbind Me!">

		<img style="display: none;" src='' onerror="window.external.Call('bind');">
	]==])
end)

wind:SetCallback(Call)
wind:Show()