passing hidden password data using Jquery Editable Bootstrap3
passing hidden password data using Jquery Editable Bootstrap3
HTML
<script src="http://vitalets.github.com/x-editable/assets/mockjax/jquery.mockjax.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.js"></script>
<link rel="stylesheet" href="http://vitalets.github.io/x-editable/assets/x-editable/bootstrap3-editable/css/bootstrap-editable.css">
<link rel="stylesheet" href="http://vitalets.github.io/x-editable/assets/bootstrap300/css/bootstrap.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.js"></script>
<p> <span id="demo"></span></p>
<div style="margin: 150px" >
<a href="#" class="username" data-ps="">sdb&^%$</a>
</div>
<hr>
<div style="margin: 150px" >
<a href="#" class="username" data-ps="">user11123</a>
</div>
JavaScript
$("a.username").filter(function() {
return true;
}).each(function() {
$(this).text("•••••••••••");
});
$('.username').editable({
style: 'display:inline',
type: 'password',
url: '/post',
pk: 1,
title: 'Enter username',
ajaxOptions: {
dataType: 'json'
},
success: function(response, newValue) {
//alert($(this).attr('class'));
$(this).data('ps', newValue);// stores new value but does not show to screen
$("#demo").html($(this).data("ps") ); // testing only
if(!response) {
return "Unknown error!";
}
if(response.success === false) {
return response.msg;
}
}
});
//ajax emulation
$.mockjax({
url: '/post',
responseTime: 200,
response: function(settings) {
if(settings.data.value) {
// alert(settings.data.value);
this.responseText = '{"success": true}';
} else {
this.responseText = '{"success": false, "msg": "required"}';
}
}
});