Bruce Gust
asked on
Tell me if I understand this correctly...
Here's the HTML that sets everything in motion:
<li role="presentation"><a href="#summary" aria-controls="summary" role="tab" data-toggle="tab">Health Summary</a></li>
"#summary" - triggers this function:
$('a[href="#summary"]').on ('click', function(){
setTimeout(function(){
HealthSummary.init();
}, 250);
});
HealthSummary.init - not sure what that means other than, "initialize." There's another script has this:
What's happening, here?
I'm thinking that on line 24, you're getting a page and, according to the routing (this is a Laravel app), you're getting this:
"health_summary": {
"url": "/health-summary/{id}",
"handler": "HealthSummary.php",
"action": "_default",
"method": ["get"],
"security": ["user"]
},
...health-summary/{id} That's the URL and the "HealthSummary.php" is the systemic scaffolding behind that page.
Correct?
<li role="presentation"><a href="#summary" aria-controls="summary" role="tab" data-toggle="tab">Health Summary</a></li>
"#summary" - triggers this function:
$('a[href="#summary"]').on
setTimeout(function(){
HealthSummary.init();
}, 250);
});
HealthSummary.init - not sure what that means other than, "initialize." There's another script has this:
var HealthSummary = {
initialized: false,
init: function(){
var self = this;
if (self.initialized) {
return true;
}
$('.health-summary[data-id]').each(function(i){
var $this = $(this),
id = $this.attr('data-id');
if (id === '') {
$this.html('<h3 class="text-center">Invalid health summary reference</h3>');
return true;
}
$this.html('<h3 class="text-center"><i class="fa fa-refresh fa-spin"></i> Loading Health Summary...<br /><small>(This should only take a few seconds.)</small></h3>');
$.get('/health-summary/' + id, function(resp){
if (resp.error) {
$this.html('<div class="alert alert-danger">' + resp.msg + '</div>');
return false;
}
$this.html(resp.data.html);
}, 'json').fail(function(){
$this.html('<div class="alert alert-danger">Unfortunately, something appears to have gone wrong. Please refresh the page to try again.</div>');
});
});
self.initialized = true;
}
};
What's happening, here?
I'm thinking that on line 24, you're getting a page and, according to the routing (this is a Laravel app), you're getting this:
"health_summary": {
"url": "/health-summary/{id}",
"handler": "HealthSummary.php",
"action": "_default",
"method": ["get"],
"security": ["user"]
},
...health-summary/{id} That's the URL and the "HealthSummary.php" is the systemic scaffolding behind that page.
Correct?
ASKER
So, I am barking up the right tree, yes...
$('a[href="#summary"]').on ('click', function(){
setTimeout(function(){
HealthSummary.init();
}, 250);
});
This is instantiating the "HealthSummary" object which is "var HealthSummary=" and all the functionality that follows, yes?
I'm pretty sure about the Laravel routing - one of the advantages of working with a page that works. But I wanted to get someone else's eyes on my logic in terms of the "flowchart" with the link -> $('a[href="#summary"]').on ('click', function(){ -> HealthSummary object.
That's the right flow, yes?
$('a[href="#summary"]').on
setTimeout(function(){
HealthSummary.init();
}, 250);
});
This is instantiating the "HealthSummary" object which is "var HealthSummary=" and all the functionality that follows, yes?
I'm pretty sure about the Laravel routing - one of the advantages of working with a page that works. But I wanted to get someone else's eyes on my logic in terms of the "flowchart" with the link -> $('a[href="#summary"]').on
That's the right flow, yes?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, gentlemen!
I've got another question at https://www.experts-exchange.com/questions/29025252/How-do-I-pass-another-variable-into-this-function.html. If you've got the time, I would welcome the input.
Thanks, again!
I've got another question at https://www.experts-exchange.com/questions/29025252/How-do-I-pass-another-variable-into-this-function.html. If you've got the time, I would welcome the input.
Thanks, again!
You are welcome.
init() is a method (aka "function") of the object.
I'm not exactly sure about the relationship between the Laravel route for /health-summary/ and the script HealthSummary.php. It looks and feels right, based on my experience with Laravel, but it might be worth looking at the routing in Laravel to be sure.