Просмотр исходного кода

Use atoms in the generation of target

Panel=atom_id,
wf:wire(#bind{target={qs,["[id='",Panel,"'] button:nth-child(2)"]},type=click,postback="console.log(200);"}),
Andy 8 лет назад
Родитель
Сommit
5ba3d3d937
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      src/render/wf_event.erl

+ 4 - 3
src/render/wf_event.erl

@@ -9,8 +9,9 @@
 -define(CTX, (get(context))).
 
 -define(B(E), nitro:to_binary(E)).
-target({qs,S}) -> ["qs('",S,"')"];
-target(Id)     -> ["qi('",?B(Id),"')"].
+-define(L(E), nitro:to_list(E)).
+target({qs,S}) -> ["qs('",nitro:js_escape(?L(S)), "')"];
+target(Id)     -> ["qi('",nitro:js_escape(?L(Id)),"')"].
 
 new(P,E,D,N,Data,Source) -> new(P,E,D,N,Data,Source,<<>>).
 
@@ -24,4 +25,4 @@ new(Postback, Element, Delegate, Name, Data, Source, Validation) ->
     Event = #ev{name=Name, module=Module, msg=Postback, trigger=Element},
     list_to_binary(["{ if (validateSources([",Join([ nitro:to_list(S) || S <- Source, S =/= []]),
         "])) { ",?B(Validation)," ws.send(enc(tuple(atom('",?B(application:get_env(n2o,event,pickle)),"'),bin('",
-        Element,"'),bin('",nitro:pickle(Event),"'),",Data,"))); } else console.log('Validation Error'); }"]).
+        Element,"'),bin('",nitro:pickle(Event),"'),",Data,"))); } else console.log('Validation Error'); }"]).