Comments (1)
Hi there,
I think you could resolve the problem by using "reload" method.
At using the "reload" method, you can rebuild the timeline included all events. At that time, usualy all events on the timeline will be re-rendered from cache in browser however you can replace new events to re-rendered the timeline if it set false to the "reloadCacheKeep" option.
Therefore you should reset currently events then modify to events retrieved via ajax before firing the "reload" method.
An example is as follows:
<div id="my-timeline">
<ul class="timeline-events">
<li data-timeline-node="{ start:'2019-01-20 14:00',end:'2019-01-24 13:59',row:1}">Default Event 1</li>
<li data-timeline-node="{ start:'2019-01-21 10:30',end:'2019-01-25 9:59',row:2 }">Default Event 2</li>
</ul>
</div>
let my_options = {
type : 'bar',
startDatetime : '2019-01-17 0:00:00',
scale : 'day',
minGridSize : 24 * 2,
sidebar : {
sticky : true,
list : [
'<a href="#"> Row 1</a>',
'<a href="#" class="narrow-row2"> Row 2</a>',
'<a href="#"> Row 3</a>',
'<a href="#"> Row 4</a>',
'<a href="#"> Row 5</a>',
'<a href="#"> Row 6</a>',
'<a href="#"> Row 7</a>',
]
},
ruler : {
top : {
lines : [ 'year', 'month', 'day', 'weekday' ],
},
},
reloadCacheKeep : false,
}
$('#my-timeline').Timeline( my_options )
// Fire reload
$(document).on('click','.narrow-row2',function() {
// Reset currently events then modify to events retrieved via ajax
$('.timeline-events').empty().append(`
<li data-timeline-node="{ start:'2019-01-25 10:00',end:'2019-01-27 23:59',row:2,bgColor:'red',color:'yellow' }">Async loadead event-1</li>
<li data-timeline-node="{ start:'2019-01-27 10:00',end:'2019-01-29 23:59',row:4,bgColor:'red',color:'yellow' }">Async loadead event-2</li>
`);
$('#my-timeline').Timeline('reload', {
// You can override any options when reload the timeline
sidebar : {
list : [
'<a href="#"> Row 2-1</a>',
'<a href="#"> Row 2-2</a>',
'<a href="#"> Row 2-3</a>',
'<a href="#"> Row 2-4</a>',
]
}
}, function(e,c,d){ console.log( 'Reloaded Timeline!', e, c, d ) }, { userdata: 'custom' } )
})
Notice: if you retrieve events via async for re-rendering without deferred, the jquery.timeline plugin may be not able to get all events before re-rendering. At that time you should try to use jquery.deferred feature.
Thank you,
from jquery.timeline.
Related Issues (20)
- Are dynamic row heights possible? My events shall have different heights and the row shall adapt HOT 1
- Months in Spanish are lowercase, also wrong ordinal translation. HOT 1
- Fixed height and vertical scroll bar HOT 1
- Alignment crash on firefox HOT 1
- hoverEvent HOT 1
- eventMeta formatting HOT 1
- Getting error Cannot read properties of undefined (reading 'fn') HOT 3
- Ignore dates without data
- Possibility to make header ruler sticky HOT 2
- add event issue
- import with requireJS
- Events being copied after reload HOT 1
- Overlapping Events should display on different lines but in the same row
- Conflict with Vuejs
- test.js:3 Uncaught TypeError: $(...).timeline is not a function HOT 5
- Remote events data HOT 2
- event drag and drop feature HOT 1
- Scale half-hour
- Introduce Sunorhc.Timeline
- Ancient time BC
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.timeline.