Reputation: 27
I have div-> id ids that when I right-click I display a window, when a simple click gets the data, but when I right click through $.contextMenu for the first time, that data is maintained for all div->id.
$('.w_content').click(function (e){
e.preventDefault();
var wor = $( e.target ).attr('id');
console.log(wor);
$.contextMenu({
selector: '.wcontext',
callback: function(key, options) {
// console.log(wor);
$('#dialog-form').dialog('open');
$.ajax({
url: '<?php echo base_url()?>documentos/getDocDetalleAjax',
data: {id: dat.id_documento,orden:wor},
type: 'POST',
cache: false,
success: function ( msg ){
console.log(msg);
// if (typeof msg[index] == 'undefined' || msg[index] == null) {
// console.log('sisis');
// }
// var wd = $.parseJSON ( msg );
// $('#dtitulo').val(wd.titulo);
// console.log(msg);
}
});
},
items: {
"edit": {name: "Edit", icon: "edit"},
"sep1": "---------",
"quit": {name: "Quit", icon: function(){
return 'context-menu-icon context-menu-icon-quit';
}}
}
});
});
The id is within the class = ".w_content"
Thanks for your help
Upvotes: 0
Views: 68
Reputation: 744
Are you using the same id
on different elements? An id
attribute value is meant to be unique. If you have multiple elements with the same id
you're going to start running in to JavaScript, CSS and possibly even HTML problems. Use CSS classes if you want to target multiple elements.
Upvotes: 1