can you suggest what i should do in this scenario, I have a couple of div in HTML, and i want id=plot_selector to wait until the user right-click because when the user right-clicks, I use jquery to get the info of the row on which the user right click and send it to the controller, then I will call id=plot_selector to execute because the value of plot_list in that id will change after the user right-click. is there any way that I can do that or ask div to execute again so that it will have the updated plot_list variable after the user right-click? in the other words, i want to make the div in view constantly running every time the user right click on different rows instead of running once at the beginning this is my jquery in view:
<script> //Function to handle context menu appearing/disappearing $(function() { var contextMenu = $("#contextMenu"); var $rowClicked //body on contextmenu is the event for right clicking $(document.body).on("contextmenu", "table tr", function(e) { var tableData = $(this).children("td").map(function(){ return $(this).text(); }).get(); ajax('{{=URL('project','view','view_custom_search')}}' + '?clickedFlight=' + tableData[0], []); //send this to controller and the div should execute after this . contextMenu.css({ display: "block", left: e.clientX, //TODO: figure out why I have to hardcode this value to get the menu to appear in correct place //...Y axis page value not correctly displaying on table top: e.clientY - 80 }); return false; }); $('html').click(function(e) { contextMenu.hide(); }); }); $(document).ready(function() { var plot_context_menu = $("#plot_context_menu"); var table_container = $("#table_container"); var plot_container = $("#plot_container"); //plot_container.hide(); $(plot_context_menu).click(function(e) { $('#contextMenu').hide(); table_container.attr('class', 'col-md-6'); plot_container.show(); return false; }); $('#plot_choice').change(function () { $('#plot_choice option:selected').each(function(){ <!-- if new file in the drop down menu selected, hide class named plot_path, and display the selected id (each file in the menu is assoicated with ID) --> var graph = $( this ).val() $('.plot_path').hide(); $('#' + graph).show(); return false; }) }) }); </script> this is the div in the view that i want to execute after the ajax statement so that the Plot_list variable will get the new value after the ajax statement in jquery <div class = 'col-md-4' id = 'plot_selector'> <select name = 'plot_choice' class = 'form-control' id = 'plot_choice'> {{for r in plot_list:}} <option value = {{=plot_list.index(r)}}> {{=r}} </option> {{pass}} </select> <br> </div> On Wednesday, July 10, 2019 at 2:19:50 PM UTC-7, Dave S wrote: > > > > On Wednesday, July 10, 2019 at 6:19:00 AM UTC-7, Quang Lam wrote: >> >> but this one still cause the section id "thisone" execute when the page >> is loaded. i want this one to hold off until the user right click and >> select an option in the menu because the section id "thisone" needs the >> information of the row on which the user right click. if this section id >> "thisone execute before the user right click, some of the variables will be >> empty >> > > "Execute" may be a poor term for a non-procedural language like HTML and > CSS. Javascript, of course, is procedural, and "execute" is a natural term > there. > > In any case, if a DIV is declared when the page is loaded (that is, <DIV > id=x> is in the html file), it's contents and attributes are evaluated > then. They can be changed. The onclick handler can change contents, just > as it changes the visibility attribute. > > The other approach is to not have the DIV in the html file, and to use the > onclick handler to insert the DIV into the DOM. The trick to that is to > have the id of the element that the DIV is inserted into. > > Finally, you can use the LOAD() helper to replace an empty DIV with the > content returned from a request to the server (that's different from > copying from another element, as in propagating the cell contents from a > grid entry). It's a wrapper for AJAX, and I believe it uses jQuery under > the hood. And if you need more control, you can unwrap the jQuery and do > it yourself. > > I'm not the javascript expert in the group, but I've done various bits of > this. > > /dps "on my good days I might pass as a journeyman jscripter" > > > >> On Wed, Jul 10, 2019 at 3:38 AM Dave S <snide...@gmail.com> wrote: >> >>> >>> >>> On Tuesday, July 9, 2019 at 7:08:48 PM UTC-7, Quang Lam wrote: >>>> >>>> i have multiple <div> in my html page and i dont want all of them to be >>>> executed when the page is loaded. is there any way that we can delay it >>>> until the user right click on the context menu. i dont want to use >>>> selector.show or selector.hide. because i want those <div> to be executed >>>> after the user right click >>>> >>> >>> The way I do it is to use [style].visiblity = "hidden", and toggle it >>> document.getElementById("thisone").style.visibility = visible; >>> >>> and do that by using an onclick handler. >>> >>> /dps >>> >>> -- >>> Resources: >>> - http://web2py.com >>> - http://web2py.com/book (Documentation) >>> - http://github.com/web2py/web2py (Source code) >>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "web2py-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to web...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/web2py/edd2271a-97ec-424d-a0a6-1edd4114e417%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/web2py/edd2271a-97ec-424d-a0a6-1edd4114e417%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/4becbece-c40d-475c-be8f-f13d049c97ef%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.