File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -7,3 +7,5 @@ When an element is equipped with class="pat-push" and a push ID it will listen t
77 data-pat-push="push-id: message_counter; url: /message-counter">
88Messages <sup class =" counter digit-1 " >1</sup >
99</a >
10+
11+ If you add the ` mode: append ` option, the fetched content will be appended to the element.
Original file line number Diff line number Diff line change 1+ < li > A < strong > new</ strong > message</ li >
Original file line number Diff line number Diff line change @@ -42,5 +42,18 @@ <h2>push-id: message_counter2</h2>
4242 >
4343 messages < sup class ="counter digit-1 "> 1</ sup >
4444 </ div >
45+
46+ < h2 > push-id: message_incoming; mode: append</ h2 >
47+ < div >
48+ If a message is sent through RabbitMQ on the "patternslib" exchange on the
49+ push_marker topic containing the message "message_incoming" the list below
50+ will be updated.
51+ < ul
52+ class ="pat-push "
53+ data-pat-push ="push-id: message_incoming; url: index-push-messages.html; mode: append "
54+ >
55+ < li > Old message</ li >
56+ </ ul >
57+ </ div >
4558 </ body >
4659</ html >
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const logger = logging.getLogger("push");
88export const parser = new Parser ( "push" ) ;
99parser . addArgument ( "url" , null ) ;
1010parser . addArgument ( "push-id" , null ) ;
11+ parser . addArgument ( "mode" , "replace" ) ;
1112
1213export default Base . extend ( {
1314 name : "push" ,
@@ -32,7 +33,11 @@ export default Base.extend({
3233 try {
3334 const response = await fetch ( this . options . url ) ;
3435 const data = await response . text ( ) ;
35- this . el . innerHTML = data ;
36+ if ( this . options . mode === "append" ) {
37+ this . el . insertAdjacentHTML ( "beforeend" , data ) ;
38+ } else {
39+ this . el . innerHTML = data ;
40+ }
3641 } catch ( e ) {
3742 logger . error (
3843 `Could not fetch from ${ this . options . url } on push-id ${ this . options . pushId } .`
You can’t perform that action at this time.
0 commit comments