Having an issue with passing javascript variables to a controller (as in a
click or button call).
A common thread running through all the attempts is an error in loading
jquery, returning a 404 error.
As a simple example, consider the following:
*MODEL:*
db.define_table('dogs',
Field('dog_name','string'),
Field('dComment','string'))
db.define_table('fleas',
Field('dog_name','string'),
Field('flea_name','string'),
Field('fDescription','string'))
*CONTROLLER:*
def populate():
db.dogs.truncate()
db.fleas.truncate()
db.dogs.insert(dog_name='dagwood')
db.dogs.insert(dog_name='daisy')
db.fleas.insert(dog_name='daisy', flea_name='felix')
db.fleas.insert(dog_name='dagwood', flea_name='fatso')
def dogs():
g = SQLFORM.grid(db.dogs, searchable=False, csv=False)
return dict(form = g)
def fleas():
q = (db.fleas.dog_name == request.vars.dog_name)
g = SQLFORM.grid(q, searchable=False, csv=False)
return dict(form = g)
*VIEW:*
DOGS
{{extend 'layout.html'}}
<div id='dogs'>
{{=form}}
</div>
<div id='fleas'>
</div>
<script>
$(document).ready(function(){
$('tr').click(function () {
var rec_id = $(this).find('td').eq(0).text();
ajax("fleas"+"?"+rec_id,[],'fleas');});})
</script>
(basically the same as the solution proposed by Anthony in
https://groups.google.com/forum/#!searchin/web2py/pass$20variable$20to$20controller/web2py/5rXctmuIj9o/J9b1wQDIiPsJ
)
FLEAS:
{{=fleas}}
*Procedure*:
click on a row, it should make a call to flea function, but returns a
......jquery-1.10.0.min.map 404 error
(using a 2.5.1 fresh stable version)
Any pointers?
--
---
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].
For more options, visit https://groups.google.com/groups/opt_out.