My page layout has two main divs. One on the left and the other on the right. I tried reloading only the DIV on the left after submitting form via ajax.
$(".left-content").load('left.php');
left.php
contains HTML for the left DIV. After refreshing, it does load the html and the div looks fine but not working. Any of the jQuery functions or anchor links are not working.
So I tried the following:
Previously was:
$("#slider").mousemove( function(e){
$("#valBox").html($(this).val());
});
Added now, to detect newly added DOM elements:
$('body').on('mousemove', '#slider', function() {
$("#valBox").html($(this).val());
});
previously was, for popup box:
<a href="#browse-search-popup" class="browse-search-popup-link"><span id="searchLink" style='color:#fff;text-decoration:underline;font-weight:bold !important;' class='text-center'>browse courses</span></a>
Added now, for newly added DOM elements
if(window.location.href.indexOf("#browse-search-popup") != -1)
{
$('.browse-search-popup-link').click();
}
Can someone explain what's the possibility for this to happen where no functions is working. Could it be possible duplicate ID? But when a DIV is reloaded isn't replaced with content specified 'left.php'
where there's no chance for duplicate ID to occur?
master page (left-content) div
<div class="small-12 medium-12 large-12 left-content hide-for-small hide-for-medium columns">
<div class="small-6 medium-6 large-8 columns titleBox hide-for-small hide-for-medium">
<p>Find Tutors</p>
</div>
<br/><br/><br/><br/>
<form name="form" id="search_tutor" method="post" action="#" class="hide-for-small">
<!-- class => which item to select in autocomplete eg: class="1"-->
<input id="subject" type="text" name="subject" value="" placeholder="Subject" class="1 text-center"/ style="width:200px;margin:0 auto;" required>
<input type="hidden" name="try" value="" />
<div class="small-12 medium-12 large-12 text-center columns" style="padding:10px 0;">
<span id="searchLink">or </span><a href="#browse-search-popup" class="browse-search-popup-link"><span id="searchLink" style='color:#fff;text-decoration:underline;font-weight:bold !important;' class='text-center'>browse courses</span></a>
</div>
<!-- <div class="ui-widget2">-->
<input id="location_input" type="text" name="location" value="" placeholder="Location" class="0 text-center" style="width:200px;margin:0 auto;" required>
<input type="hidden" name="lat" value="" />
<input type="hidden" name="lon" value="" />
<br/><br/>
<div class="small-12 medium-12 large-12 text-center columns">
<input name="rate" type="range" min="10" max="300" step="10" value="100" id="slider"/>
</div>
<br/><br/>
<div class="text-center">Within <span>RM</span><span id="valBox">100</span></div><br/>
<div class="small-12 medium-12 large-12 text-center columns">
<input name="distance" type="range" min="5" max="300" step="5" value="40" id="slider2"/><br/><br/>
</div>
<div class="text-center">Within <span id="valBox2">40</span><span>km</span></div><br/>
<div class="small-12 medium-12 large-9 large-centered text-center columns">
<a href="#more-popup" class="more-popup-link"><div class="moreBox">More Options <img src="<?php echo $path;?>/img/nav-icon.png" style="width:25px;"></div></a>
</div>
<!--more option starts-->
<div id="div1"></div><!-- style="height:100px;display:none;"-->
<div id="div2"></div>
<div id="div3"></div>
<!--<div id="capturePers">
</div>
<div id="captureTuit">
</div>
<div id="captureAvail2">
</div>-->
<!--more option ends-->
<div class="text-center">
<input type="submit" class="text-center"name="submit" value="Search" id="search"></div><br/>
</form>
</div>
left.php
<div class="small-6 medium-6 large-8 columns titleBox hide-for-small hide-for-medium">
<p>Find Tutors</p>
</div>
<br/><br/><br/><br/>
<form name="form" id="search_tutor" method="post" action="#" class="hide-for-small">
<!-- class => which item to select in autocomplete eg: class="1"-->
<input id="subject" type="text" name="subject" value="" placeholder="Subject" class="1 text-center"/ style="width:200px;margin:0 auto;" required>
<input type="hidden" name="try" value="" />
<div class="small-12 medium-12 large-12 text-center columns" style="padding:10px 0;">
<span id="searchLink">or </span><a href="#browse-search-popup" class="browse-search-popup-link"><span id="searchLink" style='color:#fff;text-decoration:underline;font-weight:bold !important;' class='text-center'>browse courses</span></a>
</div>
<!-- <div class="ui-widget2">-->
<input id="location_input" type="text" name="location" value="" placeholder="Location" class="0 text-center" style="width:200px;margin:0 auto;" required>
<input type="hidden" name="lat" value="" />
<input type="hidden" name="lon" value="" />
<br/><br/>
<div class="small-12 medium-12 large-12 text-center columns">
<input name="rate" type="range" min="10" max="300" step="10" value="100" id="slider"/>
</div>
<br/><br/>
<div class="text-center">Within <span>RM</span><span id="valBox">100</span></div><br/>
<div class="small-12 medium-12 large-12 text-center columns">
<input name="distance" type="range" min="5" max="300" step="5" value="40" id="slider2"/><br/><br/>
</div>
<div class="text-center">Within <span id="valBox2">40</span><span>km</span></div><br/>
<div class="small-12 medium-12 large-9 large-centered text-center columns">
<a href="#more-popup" class="more-popup-link"><div class="moreBox">More Options <img src="<?php echo $path;?>/img/nav-icon.png" style="width:25px;"></div></a>
</div>
<!--more option starts-->
<div id="div1"></div><!-- style="height:100px;display:none;"-->
<div id="div2"></div>
<div id="div3"></div>
<!--<div id="capturePers">
</div>
<div id="captureTuit">
</div>
<div id="captureAvail2">
</div>-->
<!--more option ends-->
<div class="text-center">
<input type="submit" class="text-center"name="submit" value="Search" id="search"></div><br/>
</form>
</div>
</div><!--end row-->