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
7
7
data-pat-push="push-id: message_counter; url: /message-counter">
8
8
Messages <sup class =" counter digit-1 " >1</sup >
9
9
</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>
42
42
>
43
43
messages < sup class ="counter digit-1 "> 1</ sup >
44
44
</ 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 >
45
58
</ body >
46
59
</ html >
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const logger = logging.getLogger("push");
8
8
export const parser = new Parser ( "push" ) ;
9
9
parser . addArgument ( "url" , null ) ;
10
10
parser . addArgument ( "push-id" , null ) ;
11
+ parser . addArgument ( "mode" , "replace" ) ;
11
12
12
13
export default Base . extend ( {
13
14
name : "push" ,
@@ -32,7 +33,11 @@ export default Base.extend({
32
33
try {
33
34
const response = await fetch ( this . options . url ) ;
34
35
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
+ }
36
41
} catch ( e ) {
37
42
logger . error (
38
43
`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