0
I’ve got three inline-block divs on an 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 inside 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 on 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 don’t understand the reason for this behavior.
I’m not really into Javascript, and any help was appreciated.
It solved the double click problem but now it cannot return to its original state .. It was for this very reason that I modified the script as shown above. It seems that it does not recognize the link that came up after extending the div..
– Bruno Monteiro
Add the content inside a div with a class or id, then to return to the original state just remove this div.
– Aline
But the original div is not replaced in the course of the function? The script does not recognize the link ". more" from the original div (already replaced back)... The concept was user could extend and decrease the Divs individually without refreshing the page.
– Bruno Monteiro
Add your HTML, please. All the expanding div and etc.
– Aline