I'm currently working on a homemade 100 percent javascript CMS in our office and I have a problem. Some editable areas that the user can edit are contained in the href link. These hrefs are NOT editable, but when the user clicks on these zones (in edit mode), the browser follows these links.
First, heres an example of html generated by CMS:
<span id ="8a8b8d2e262bde2d01262c08317c000c" class="document">
<a href="/actions/ecommerce/viderSelectionPalierEtVitrine">
<img src="/images/logo.gif" id="8a8b8d2e262bde2d01262c08bf83000d" title="" alt="" class="image logo" />
</a>
</span>
Here, for example, the user can only change; So I tried to control the surrounding href this way:
var referenceZone = $(this).attr("id");
$("#"+documentId+" a").each(function() {
$(this).click(function() {
return false;
});
});
Where referenceZone is my environment <span id ="8a8b8d2e262bde2d01262c08317c000c" class="document">
Is it really that hard as it seems to me?
<**** EDIT ****> Added sandbox for testing purposes here: http://jsbin.com/aboke/2
<**** EDIT 2 ****> I do not understand that alert (event.type) doesn't even work !!
$("span#" + documentId + " a").click(function(event) {
alert(event.type);
event.preventDefault();
suppressionZoneModifiable(documentId);
recupererTexte(referenceZone, documentId);
});