I have 3 inline-block Divs in a row. These divs contain 1 text paragraph with a link at the end to extend the div and print the remaining paragraphs. At the end of the extended div, there is another link that returns the div to its normal state. To achieve this, I use the following scripts:
<script type="text/javascript" charset="utf-8">
function mor() {
$(document).ready(function () {
$('.more').click(function () {
$('#' + $(this).attr('id')).load('content-box_en.phtml #' + $(this).attr('id') + '-p');
return false;
});
});
}
</script>
<script type="text/javascript" charset="utf-8">
function res() {
$(document).ready(function(){
$('.reset').click(function(){
$('#'+$(this).attr('id')).load('reset_en.phtml #' + $(this).attr('id')+'-p');
return false;
});
});
}
</script>
The divs link looks like this:
<p>Mobile sales System – Mobile application for Pre- Sales and Auto sales, distribution and tecnical services. Available to PDA and Tablet. <a class="more" id="sales" href="javascript:mor()" style="text-decoration: none;">[+]</a></p>
The content within the file "content-box_en.phtml":
<p id="sales-p"><?= mb_convert_encoding('Mobile sales System – Mobile application for Pre- Sales and Auto sales, distribution and tecnical services. Available to PDA and Tablet.', 'UTF-8') ?></p>
<p id="sales-p"><?= mb_convert_encoding('Mobile sales System – Mobile application for Pre- Sales and Auto sales.', 'UTF-8')?><a class="reset" id="sales" href="javascript:res()" style="text-decoration: none;">[-]</a></p>
This functional, the problem arises when I click the link for the first time. I have to double click the first time I call the function, but then it works with a single click ...
I do not understand the reason for this behavior. I'm not much into Javascript, and any help was appreciated.