666kronos666 Posted June 11, 2012 at 05:42 PM Report Share #462032 Posted June 11, 2012 at 05:42 PM (edited) Olá a todos, Estou mais ou menos que a aprender JQuery, e tenho dois problemas com um script que talvez alguém me possa ajudar. A rotina em funcionamento podem ver em... http://hotel.sys.pt/...ame=CF1&modul=1 1º problema é que ao clicar com o botão direito do rato num rectângulo child é o mesmo que clicar em todos os parents e isto não é aceitável para o que pretendo. 2º preciso que as coordenadas do ponto de click sejam globais, e não está a acontecer. Resumidamente, o código é: var i = ''; var xMouse = 0; var yMouse = 0; $(document).ready(function(){ //LÊ O MÓDULO DA BASE DE DADOS $.ajax({ type: "POST", url: 'modules.php?name=CF1&opt=action_Load_Module&modul='+modul, async: false, success: function (data) { cells=eval('(' + data + ')'); } }); //CARREGA AS CÉLULAS DO MÓDULO $.each(cells, function(i) { if(cells[i]['cell'] == '0') { // CÉLULA BASE $("#cell_0").addClass('container'); $("#cell_0").css("position", "absolute"); $("#cell_0").css("left", ""+cells[i]['topx']+""); $("#cell_0").css("top", ""+cells[i]['topy']+""); $("#cell_0").css("width", ""+cells[i]['botx']+""); $("#cell_0").css("height", ""+cells[i]['boty']+""); $("#cell_0").charge_cell(0); } else { // SUB-CÉLULAS var width = cells[i]['botx'] - cells[i]['topx']; var hight = cells[i]['boty'] - cells[i]['topy']; $("#cell_"+cells[i]['prec']).append('<div id="cell_'+i+'" class="cells" style="position:absolute; left:'+cells[i]['topx']+'px; top:'+cells[i]['topy']+'px; width:'+width+'px; height:'+hight+'px; padding:0px;">'+i+'</div>'); $('#cell_'+i).addClass('cells_'+cells[i]['tcel']); $('#cell_'+i).charge_cell(i); } }); //CONTEXTMENU DE SUB-CÉLULA $('.cells').mousedown(function(e) { if (e.which === 3) { var i = this.id.replace("cell_",""); xMouse = e.pageX - this.offsetLeft - 187; yMouse = e.pageY - this.offsetTop - 196; alert('ID: '+this.id+' | X: ' + xMouse + ' | Y: ' + yMouse) $.contextMenu( { selector: "#cell_"+cells[i]['cell'], build: function($trigger) { var options = { callback: function(key, options) { var fn = key; if (fn in window) { window[fn](cells[i]['cell']); } }, items: "" }; var fn = 'contextMenu_cells_' + cells[i]['tcel']; if(fn in window) { options.items = window[fn](cells[i]['cell']); return options; } else { alert('ERROR! TYPE '+cells[i]['tcel']+' HAS NO CONTEXTMENU.'); options.items = { "error": {name: "", icon: "", val: i} }; } } }); } }); //CONTEXTMENU DA CÉLULA BASE $('.container').mousedown(function(e) { if (e.which === 3) { var i = this.id.replace("cell_",""); xMouse = e.pageX - this.offsetLeft; yMouse = e.pageY - this.offsetTop; alert('ID: '+i+' | X: ' + xMouse + ' | Y: ' + yMouse) $.contextMenu({ selector: "#cell_"+cells[i]['cell'], build: function($trigger) { var options = { callback: function(key, options) { var fn = key; if (fn in window) { window[fn](cells[i]['cell']); } }, items: "" }; var fn = 'contextMenu_cells_' + cells[i]['tcel']; if(fn in window) { options.items = window[fn](cells[i]['cell']); return options; } else { alert('ERROR! TYPE '+cells[i]['tcel']+' HAS NO CONTEXTMENU.'); options.items = { "error": {name: "", icon: "", val: i} }; } } }); } }); }); Se alguém puder ajudar, agradeço. Edited June 12, 2012 at 10:18 AM by brunoais geshi! Link to comment Share on other sites More sharing options...
666kronos666 Posted June 11, 2012 at 11:57 PM Author Report Share #462088 Posted June 11, 2012 at 11:57 PM Não sei como, mas está resolvido 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now