Re: How to pass the variable in Jquery in view to controller

33 views
Skip to first unread message
Message has been deleted

Scott Hunter

unread,
Jul 8, 2019, 9:06:29 PM7/8/19
to web2py-users
The short answer is, you don't.  Javascript is being executed in the browser; controller code is executed on the server.

The longer answer is that the browser can make a request to the server (via ajax or some other mechanism) that can cause controller code to be executed.  I think you'll need to provide more details of what you are trying to do before someone can w/ details.

On Monday, July 8, 2019 at 5:45:29 PM UTC-4, Quang Lam wrote:
Hi All, i would like to pass the variable clickedFlight in Jquery in view to one of the functions named custom_view_search in view.py in controller. Please show me how. Thanks


$(document.body).on("contextmenu", "table tr", function(e) {
var tableData = $(this).children("td").map(function(){
return $(this).text();
}).get();
var clickedFlight = tableData[0]
alert(clickedFlight);
    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;
 
    });
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages