Ralph
asked on
jQuery .on("click", handler) not doing what I need it to do
Likely an obvious mistake, but I cannot get links and functions to behave as I want them to.
Our story so far:
The .ready() function for prelist_plan_levels.html is $(document).ready(review_p lan_levels );
That function's jQuery populates the page, including some links, one of which is:
On clicking one of the links like the one shown above, I'm trying to get the following (incomplete) code to work:
=====
What happens is I get the alert for the third function, function list_plan_levels(), not either of the first two functions' alerts.
I need to do that ajax lookup and some other things before I get to that third function.
In real time I'm getting smarter WRT DataTables() and I will make some structure changes, but I still need to get past this hangup.
I've done this before, but I must be having a brain fart.
Thanks all,
Ralph
Our story so far:
The .ready() function for prelist_plan_levels.html is $(document).ready(review_p
That function's jQuery populates the page, including some links, one of which is:
<a href="/cmdb/public_html/Work/list_plan_levels.html" class="UpDowngrade" data-pp="Nov 2015" data-scope="PP" data-updown="UP">17</a>
Also, the first line of that function is
$('.UpDowngrade a').on( "click", listPlanLevelsClick ) ;
On clicking one of the links like the one shown above, I'm trying to get the following (incomplete) code to work:
// =================================================================================================
// This function responds to clicks in prelist_plan_levels.html
function listPlanLevelsClick(event)
{
event.stopPropagation();
alert("inside function listPlanLevelsClick()") ;
var UpDown='#' + $(this).data('UpDown');
var posted_period='#' + $(this).data('PP');
var scope='#' + $(this).data('scope');
var php_params = 'job=UpDownGrade&UpDown='+UpDown+'&posting_period='+posted_period+'&scope='+scope ;
$('#debug').html(php_params) ;
var jqXHR = $.ajax({
url: '/cmdb/PHP/do_DataTables_query.php' ,
method: "GET" ,
cache: false ,
data: php_params ,
success: load__list_plan_levels
}) ;
}
// -------------------------------------------------------------------------------------------------
// This function is the success callback for the AJAX that retrieved UpDowngradeable data
// When the page loads its .ready() function takes over.
function load__list_plan_levels()
{
alert("inside function load__list_plan_levels()") ;
}
// =================================================================================================
// .ready() function for page: list_plan_levels.html
function list_plan_levels()
{
$('#UpDownGrade').DataTable() ;
alert("inside function list_plan_levels()") ;
}
==========================What happens is I get the alert for the third function, function list_plan_levels(), not either of the first two functions' alerts.
I need to do that ajax lookup and some other things before I get to that third function.
In real time I'm getting smarter WRT DataTables() and I will make some structure changes, but I still need to get past this hangup.
I've done this before, but I must be having a brain fart.
Thanks all,
Ralph
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.
You are welcome
ASKER
Ralph