turning live into on in jquery doesnt work -
i had code
$(".pager .page").live("click", function () { if ($('#txtbuscador').val() == '') { getcustomers(parseint($(this).attr('page'))); } else { getcustomersbuscar(parseint($(this).attr('page'))); } });
and replace
$(document).on("click", ".pager.page", function () { if ($('#txtbuscador').val() == '' ) { getcustomers(parseint($(this).attr('page'))); } else { getcustomersbuscar(parseint($(this).attr('page'))); } });
i don't understand why doesn't work , elements .pager.page
created dynamically.
<div class="pager"> <span>1</span> <a style="cursor:pointer" class="page" page="2">2</a> <a style="cursor:pointer" class="page" page="3">3</a> </div>
try substituting ".pager .page"
".pager.page"
function getcustomers(page) { console.log("getcustomers", page) } function getcustomersbuscar(page) { console.log("getcustomersbuscar", page) } $(document).on("click", ".pager .page", function () { if ($("#txtbuscador").val() == "" ) { getcustomers(parseint($(this).attr("page"))); } else { getcustomersbuscar(parseint($(this).attr("page"))); } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script> <div class="pager"> <div class="page" page="123">click</div> </div> <input id="txtbuscador" type="text" value="" />
Comments
Post a Comment