Last active
December 19, 2015 02:19
-
-
Save rpip/5882449 to your computer and use it in GitHub Desktop.
This file contains 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
The responses attached to the examples were taken from the Params part of the events method arguments | |
in the controller as in: | |
event({_Event, Params, _TriggerId, _TargetId}, Context) -> | |
io:format("Mod_Buffer Event params : ~p", [Params]). | |
# 1 | |
{% wire id="delete-{{ buffer.id }}" action={growl text="buffer deleted"} %} | |
<a id="delete-{{ buffer.id }}" href="#delete-{{ buffer.id }}"><i class="icon-trash"></i>Delete</a> | |
RESPONSE : Nothing happens. | |
# 2 | |
{% wire id="deletenow-{{ buffer.id }}" postback="ajaxevent" postback={myevent foo=1 bar=2} %} | |
<a id="deletenow-{{ buffer.id }}" href="#deletenow-{{ buffer.id }}"><i class="icon-trash"></i>Delete Now</a> | |
RESPONSE : Nothing happens. | |
# 3 | |
<a id="delete-{{ buffer.id }}" href="#delete/{{ buffer.id }}"><i class="icon-trash"></i> | |
{% button text="Delete" class="buffer-action-btn" title="Delete this buffer" action={postback postback="{delete_buffer, {{ buffer.id }} }"} %}</a> | |
RESPONSE : This is able to send a postback event, but could not parse the {{ buffer.id }} in the postback params, but instead presented as it is '{delete_buffer, {{ buffer.id }} }' . | |
# 4 | |
{% button text="Postback" postback={my_postback arg1=1 arg2=2 buffer_id="{{ buffer.id }}"} %} | |
RESPONSE: {my_postback,[{arg1,1},{arg2,2},{buffer_id,"{{ buffer.id }}"}]} | |
# 5 | |
{% button action={notify message="{delete_buffer, {{ buffer.id }} }"} %} | |
RESPONSE : Nothing. | |
# 6 | |
{% button title="Go" action={postback postback="{buffer_delete, {{ buffer.id }}}" action={growl text="sent message"}} %} | |
RESPONSE : '{buffer_delete, {{ buffer.id }}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe it's right in your code, but on line 5, the format args need to be in a list:
io:format("Mod_Buffer Event params : ~p", [Params]).
OK, a few observations:
{% wire id=#foo.id ... %}<a id="{{ #foo.id }}" ...
But I'd have to see the rendered result to see if this really is an issue in this case.. (or take a closer look at the code)
postback="..."
is simply a string, whatever is inside that string is not parsed further.. drop the quotes and it'll work.Conclusion:
You're close.
Two things (that I can think of) has tripped you up, first, the difference in getting at template values in text vs tags, in tags, you simply write the vars and attributes and construct tuples as needed, i.e.
{% tag ..stuff... {foo bar=1 baz=id.title} ... %}
where as in normal text it would need to be..normal text, like html and stuff... {{ {foo bar=1 baz=id.title} }}....
. Second, I suspect that DOM id's and dashes don't play nice together..