Ok, I found the solution which utilizes the Dancer2::Plugin::Ajax module and is much cleaner.
The route is now
ajax '/p_details/:tab' => sub { return params->{tab}; };
I dropped the 2 javascript functions (partner_details and partner_tab) previously posted and am now using this function.
function partner_details(tab) {
$.ajax({
url: "/p_details/" + tab,
success: function( data ) {
$( "#folder" ).html( data );
}
});
};
That other js function was moved to the external js file to remove the clutter in the template file, which is now:
<script> init_folder_tabs(); </script>
<span id="top">
<h2>Partner Details</h2>
<h3>The partner details function is still in development and is not ye
+t ready to be used.</h3>
</span>
<ul id="tabs">
<li><a href="" onclick="partner_details('general')">General</a></li>
<li><a href="" onclick="partner_details('qualifier')">EDI Qualifier
+/ ID</a></li>
<li><a href="" onclick="partner_details('certificates')">Certificate
+s</a></li>
<li><a href="" onclick="partner_details('contact')">Contact Informat
+ion</a></li>
<li><a href="" onclick="partner_details('notes')">Notes</a></li>
</ul>
<div id="folder"></div>
So, now when I click on the "folder tab" link, it displays the tab name as the main content of the "folder". Now I just need to write the sub that queries the db and builds the table to be displayed.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|