i have used Ajax but it does not get any value of the clcikedFlight,
this is 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();
var clickedFlight = tableData[0]
ajax('{{=URL('default','my_action')}}' + '?clickedFlight' + clickedFlight,
[], ':eval');
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;
});
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();
})
}).change();
});
</script>
this is in controller:
def my_action():
value = request.vars.clickedFlight
response.flash = value //try to see
the output but nothing popped up.
Please help, what i want to do is when user right click, it will get the
flight info of the right clicked row and return the other info associated
with the flight.
On Tuesday, July 9, 2019 at 6:15:28 AM UTC-7, Quang Lam wrote:
>
> i need to pass the clickedFlight variable to the controller so that i will
> get the other information associated with the clickedFlight in the table,
> please show me how to do it. thanks
>
> On Mon, Jul 8, 2019 at 6:06 PM Scott Hunter <[email protected]> wrote:
>
>> 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;
>>>
>>> });
>>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/5257ab77-2e11-4824-b5b1-1876693d2034%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/web2py/5257ab77-2e11-4824-b5b1-1876693d2034%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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/866b6784-2ec7-4bd6-be1b-ce682656d8a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.