I’m currently working on a home-made full front-office 100% javascript CMS of ours, and I’m having quite a problem.
Some of the editable areas the user can edit are contained in href link. These href’s are NOT editable, yet, when the user clicks on these zones (while in edition mode) browser follows these links.
First, heres an example of html generated by the 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 the ;
So I tried to manage the surrounding href that way :
var referenceZone = $(this).attr("id");
$("#"+documentId+" a").each(function() {
$(this).click(function() {
return false;
});
});
Where referenceZone is my surrounding <span id ="8a8b8d2e262bde2d01262c08317c000c" class="document">
Is this as tricky as it seems to me ?
<**** EDIT ****>
Added a sandbox for testing purposes here : http://jsbin.com/aboke/2
<**** EDIT 2 ****>
What I don’t understand is that alert(event.type) doesn’t even fire up !!
//click event disabling on any href of curently edited ${"span.document"}
$("span#" + documentId + " a").click(function(event) {
alert(event.type);
event.preventDefault();
suppressionZoneModifiable(documentId);
recupererTexte(referenceZone, documentId);
});
Your sandbox code at http://jsbin.com/aboke/2 has many errors. Here’s a few:
1. the function argument is a string, but passed as a number
You should put quotes around the argument here:
2. the argument does not match the span id
8a8b8d2e262bde2d01262c08317c000cvs.8a8b8d2e262bde2d01262c08bf83000d3. You are using onclick instead of click in jQuery
should be
4. You have a js error
“missing ) after argument list” (line 81)