Reputation: 2787
In my script, I need all the time on form items set attributes in HTML to save previous data and evaluate the next data before doing an ajax request.
Concerning data-next-*
attributes, there are removed all the time after the script is done like this :
function actualizeTmpDataAndSpinner (){
//Notice : "Value" is position value
var a_dataValueKeys = [ "value", "is-condition", "condition-type", "condition-selector" ];
for( var k=0 ; k < a_dataValueKeys.length; k++ ){
$("*[data-previous-" + a_dataValueKeys[k] + "]").removeAttr( "data-previous-" + a_dataValueKeys[k] );
$("*[data-next-" + a_dataValueKeys[k] + "]").each( function () {
var dataNextValue = $(this).attr("data-next-" + a_dataValueKeys[k] );
$(this).attr("data-" + a_dataValueKeys[k], dataNextValue );
});
$("*[data-next-" + a_dataValueKeys[k] + "]").removeAttr("data-next-" + a_dataValueKeys[k] );
}
$(".h4a-spinner-wrapper").remove();
}
For some reasons, after data-next-*
was setup with values and removed, at a moment this following code line set attributes only in the DOM, and not in the HTML anymore :
function resetConditionForNext( $currentfieldConditionWrapper ) {
$currentfieldConditionWrapper.attr('data-next-is-condition', "false" );
$currentfieldConditionWrapper.attr('data-next-condition-type', "" );
$currentfieldConditionWrapper.attr('data-next-condition-selector', "" );
}
Output
Why data-next-is-condition
, data-next-condition-type
and data-next-condition-selector
are not visible in the HTML inspector ?
Someone has got an explanation ?
Upvotes: 0
Views: 285
Reputation: 2787
I found what happened...
As the script removes data-next-*
at the end, in order to check new attributes, I tried to use alert("stop");
like this :
if( !$conditionCheckbox.is(":checked") ){
resetConditionForNext( $currentConditionWrapper );
console.dir( $currentConditionWrapper );
alert("stop");
break;
}
But alert("stop");
is run before doing the change in HTML Inspector.
If I write an unknown javascript word like exit;
instead of alert("stop");
like this :
if( !$conditionCheckbox.is(":checked") ){
resetConditionForNext( $currentConditionWrapper );
console.dir( $currentConditionWrapper );
exit;
break;
}
The script is locked and the HTML Inspector is updated :
Upvotes: 1