%% -*- mode: nitrogen -*-
%% vim: ts=4 sw=4 et
-module (example).
-compile(export_all).
-include_lib("nitrogen_core/include/wf.hrl").
main() -> #template { file="./site/templates/bare.html" }.
title() -> "Example".
body() ->
TextID = wf:temp_id(),
wf:wire(#api{ name=control_key, tag="foo" }),
wf:wire(TextID, #event {
type = keypress,
% key "i" == 105
actions = #script { script="if (event.ctrlKey && ([105].indexOf(event.which) >= 0)) {" ++
"event.preventDefault();" ++
"event.stopPropagation();" ++
"page.control_key('" ++ TextID ++ "', event.which);}" }
}),
[
#flash{},
#textbox{ id = TextID, text = "initial text" }
].
api_event(control_key, _Tag, [TextID, KeyCode]) ->
Msg = wf:f("Control key ~p pressed in ~p", [KeyCode, TextID]),
wf:flash(Msg).
%% -*- mode: nitrogen -*-
%% vim: ts=4 sw=4 et
-module (example).
-compile(export_all).
-include_lib("nitrogen_core/include/wf.hrl").
-include_lib("records.hrl").
main() -> #template { file="./site/templates/bare.html" }.
title() -> "Example".
body() ->
[
#flash{},
#example{}
].
%% Include the automatically generated plugins directory
-include("plugins.hrl").
%% Include any application-specific custom elements, actions, or validators below
-record(example, {?ELEMENT_BASE(element_example),
attr1 :: any(),
attr2 :: any()
}).
%% -*- mode: nitrogen -*-
%% vim: ts=4 sw=4 et
-module (element_example).
-include_lib("nitrogen_core/include/wf.hrl").
-include("records.hrl").
-export([
reflect/0,
render_element/1,
api_event/3
]).
%% Move the following record definition to records.hrl:
-spec reflect() -> [atom()].
reflect() -> record_info(fields, example).
-spec render_element(#example{}) -> body().
render_element(_Record = #example{}) ->
wf:wire(#api{ target=page, name=control_key, tag="foo", delegate=?MODULE }),
TextID = wf:temp_id(),
wf:wire(TextID, #event {
type = keypress,
% key "i" == 105
actions = #script { script="if (event.ctrlKey && ([105].indexOf(event.which) >= 0)) {" ++
"event.preventDefault();" ++
"event.stopPropagation();" ++
"page.control_key('" ++ TextID ++ "', event.which);}" }
}),
#textbox{ id = TextID, text = "initial text" }.
api_event(control_key, _Tag, [TextID, KeyCode]) ->
Msg = wf:f("Control key ~p pressed in ~p", [KeyCode, TextID]),
wf:flash(Msg).
TypeError: obj(...) is undefined
http://localhost:8000/example
Line 21
Nitrogen.$anchor('.wfid_temp626544', 'page');obj('.wfid_temp626544').control_key = function() {var s = Nitrogen.$encode_arguments_object(arguments);
<!DOCTYPE html>
<html lang="en" style="height:100%">
<head>
<meta charset="utf8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Example</title>
<script src='/nitrogen/jquery.js' type='text/javascript' charset='utf-8'></script>
<script src='/nitrogen/jquery-ui.min.js' type='text/javascript' charset='utf-8'></script>
<script src='/nitrogen/livevalidation.min.js' type='text/javascript' charset='utf-8'></script>
<script src='/nitrogen/nitrogen.min.js' type='text/javascript' charset='utf-8'></script>
<script src='/nitrogen/bert.min.js' type='text/javascript' charset='utf-8'></script>
<link rel="stylesheet" href="/nitrogen/jquery-ui/jquery.ui.all.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="/nitrogen/nitrogen.css" />
<link rel="stylesheet" href="/css/style.css" />
</head>
<body style="height:98%">
<div class="flash_container wfid_temp940150 wfid_flash" ></div><input type="text" class="wfid_temp940183 wfid_temp940174 textbox" value="initial text" />
<script>
Nitrogen.$set_param('pageContext', 'N9OnBGyMtod_jyIdEDtm9FTDXk0ZNmZg5qO03hoR9aD1m_B8VOcHtlOrZwGx_ZDaogeSFqKrOU7Hi4i4WKRDIWIHjwoGmKSY-TWvFUkxTJ9HbGEktJDRk7AZFV4ZYQ_9JbONFsQ6QLesk9JwvA1Kzb1u8_HHbvNYe0KaYl4xvDKG2PQiqS5wtzE5l5qjrNPkj7OYUqVdkSM3XHR9ISt_IUDj-MzS3J7wih0HWIVs5gtSkcyRtJEQdny7riUU2AhafckM8HduzmCY0ETS0_Pf73r4hIhJv-FWFnWPI7oHEmtbQPmS');
Nitrogen.$anchor('.wfid_temp940170', 'page');obj('.wfid_temp940170').control_key = function() {var s = Nitrogen.$encode_arguments_object(arguments);
Nitrogen.$anchor('.wfid_temp940170', 'page');Nitrogen.$queue_event('page', null, 'gZuitgwcYOU4BmWxqacINjsuOS5nHuj4maDJVHKZOsx23vQIPMedssO-uBTuOMLQlW4pnNjCREMw3wMspGMuZsnMiWCB-KENpCtSlyLzKq2FncK0AIcEKuZI68WohFZC7IbEoyLXi4cQ_t5LCm6fP60n2RIBhAxM1yIKHu_X15RENS8XodJJpWwrUszcTbVuuDCjHIJ7MWhxWdAbTZtBhnmZAb5Zp71tVtiwmZ-59Uu3Po2VX6B6iCKIY0xhwMDJpu_EN4YEiqpbfgxm-f3lnXl8IKCJ3qIzNO-IsqTyheDYYJAcWoPSLM8e8JSD7nLSqKyGrr-kiWP4pQkr3LjcPFjKAOL4GVf7gT4WtC4cn-QgNmnGJjf_haXNkAIvWuBE_Gbc2Q', s);};
Nitrogen.$anchor('.wfid_temp940170', '.wfid_temp940174');Nitrogen.$observe_event('.wfid_temp940170', '.wfid_temp940174', 'keypress', function anonymous(event) {
Nitrogen.$anchor('.wfid_temp940170', '.wfid_temp940174');
Nitrogen.$anchor('.wfid_temp940170', '.wfid_temp940174');if (event.ctrlKey && ([105].indexOf(event.which) >= 0)) {event.preventDefault();event.stopPropagation();page.control_key('temp940174', event.which);}});
</script>
</body>
</html>
if (k == 'page' || k == '.page') {
return jQuery(document)
}
#api{name=control_key, tag="foo"},"
within the custom element, but the result was the same.Do you plan to publish code for your ediytle outliner. This might fit well in a project I'm currently working on.
All the best,
Lloyd R. Prentice
--
26 авг. 2015 г., в 10:01, Stephen Schaefer <s.schaef...@gmail.com> написал(а):
To unsubscribe from this group and stop receiving emails from it, send an email to nitrogenweb+unsubscribe@googlegroups.com.
To post to this group, send email to nitro...@googlegroups.com.
Visit this group at http://groups.google.com/group/nitrogenweb.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nitrogenweb+unsubscribe@googlegroups.com.
To post to this group, send email to nitro...@googlegroups.com.
Visit this group at https://groups.google.com/group/nitrogenweb.