Created
September 21, 2015 11:47
-
-
Save 5HT/37decb5d7f7ecc96b611 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(upload). | |
-compile(export_all). | |
-include_lib("nitro/include/nitro.hrl"). | |
-include_lib("kernel/include/file.hrl"). | |
-record(upload, {?CTRL_BASE(element_upload), name, value, post_write, img_tool, post_target }). | |
render_element(#upload{id=Id} = R) -> | |
Uid = case Id of undefined -> wf:temp_id(); I -> I end, | |
Uel = R#upload{id=Uid}, | |
wire(Uel), render(Uel). | |
render(#upload{id=Id} = R) -> | |
[wf_tags:emit_tag(<<"input">>, [], [ | |
{<<"id">>, Id}, | |
{<<"type">>, <<"file">>}, | |
{<<"class">>, R#upload.class}, | |
{<<"style">>, <<"display:none">>}, | |
{<<"name">>, R#upload.name} ])]. | |
wire(#upload{id=Id}=R) -> | |
JsS = wf:json([{value, R#upload.value}]), | |
error_logger:info_msg("wire option:~p", [JsS]), | |
wf:wire(wf:f("Upload('#~s',~s);", [Id, JsS])). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment