I used to keep my component data inside element's data param.
Is this good or i should use ajax call to retrieve data.
1. By data param:
<a href="#" data-core="{JSON-data}" id="item-1">
<a href="#" data-core="{JSON-data}" id="item-2">
<a href="#" data-core="{JSON-data}" id="item-3">
<a href="#" data-core="{JSON-data}" id="item-4">
Here, all data's are STATIC.
2. By Ajax:
<a href="#" id="item-1">
<a href="#" id="item-2">
<a href="#" id="item-3">
<a href="#" id="item-4">
jQuery: (Just example)
$('#item-^').on('click', function()){
// Action to Get data.
});
Which one is good ?
[ Also here "JSON-data", might be in big in data size. ]
The answer depends on the situation you are.
You can go for data param:
You can go for ajax:
If data require some inputs or interactions from the user that is dynamic in nature.
If you want to load page faster ie, you can load page without loading all data initially