Hello, I'm relatively new to web development in general and have been building an application in Flask using the Minitwit app as a scaffolding of sorts. I know on some online forms there is a behavior where you can put in something like a username or otherwise and it will populate a drop down box with fields specific to that initial entry. Such as entering a "state" and it limiting possible entries to "zip codes" within that state. I'm wondering if this is a place for jquery or if there is some other method of doing this specific to flask and if someone could provide some reference to an example. My google-fu has failed me. The only way I could think of doing it so far was to do an initial get request using a submit button to populate the options but I think it would be nicer to use Jquery. I have the database tables setup to support it, I just need a way to pre-populate data for the fields based on a userid. Thanks! James
Use flask-sijax. Take a look at the examples. I would have provided actual code but I am on a mobile device. Sorry. On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote: > Hello, > > I'm relatively new to web development in general and have been building an > application in Flask using the Minitwit app as a scaffolding of sorts. > > I know on some online forms there is a behavior where you can put in > something like a username or otherwise and it will populate a drop down box > with fields specific to that initial entry. Such as entering a "state" and > it limiting possible entries to "zip codes" within that state. > > I'm wondering if this is a place for jquery or if there is some other > method of doing this specific to flask and if someone could provide some > reference to an example. My google-fu has failed me. > > The only way I could think of doing it so far was to do an initial get > request using a submit button to populate the options but I think it would > be nicer to use Jquery. I have the database tables setup to support it, I > just need a way to pre-populate data for the fields based on a userid. > > Thanks! > > James >
You may also want to look at using AngularJS (angularjs.org). Here is a list of examples - https://github.com/angular/angular.js/wiki/JsFiddle-Examples and a specific example on chained dropdowns - http://jsfiddle.net/KkdfV/35/ On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com> wrote: > Use flask-sijax. Take a look at the examples. I would have provided > actual code but I am on a mobile device. Sorry. > On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote: > >> Hello, >> >> I'm relatively new to web development in general and have been building >> an application in Flask using the Minitwit app as a scaffolding of sorts. >> >> I know on some online forms there is a behavior where you can put in >> something like a username or otherwise and it will populate a drop down box >> with fields specific to that initial entry. Such as entering a "state" and >> it limiting possible entries to "zip codes" within that state. >> >> I'm wondering if this is a place for jquery or if there is some other >> method of doing this specific to flask and if someone could provide some >> reference to an example. My google-fu has failed me. >> >> The only way I could think of doing it so far was to do an initial get >> request using a submit button to populate the options but I think it would >> be nicer to use Jquery. I have the database tables setup to support it, I >> just need a way to pre-populate data for the fields based on a userid. >> >> Thanks! >> >> James >> >
Thanks, I think AngularJS looks a little more on my level, other than it being a little kludgy. I'll take a look at both! On Wed, Oct 3, 2012 at 10:21 AM, Sean Lynch <techniq35@gmail.com> wrote: > You may also want to look at using AngularJS (angularjs.org). > > Here is a list of examples - > https://github.com/angular/angular.js/wiki/JsFiddle-Examples > and a specific example on chained dropdowns - > http://jsfiddle.net/KkdfV/35/ > > > On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com>wrote: > >> Use flask-sijax. Take a look at the examples. I would have provided >> actual code but I am on a mobile device. Sorry. >> On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote: >> >>> Hello, >>> >>> I'm relatively new to web development in general and have been building >>> an application in Flask using the Minitwit app as a scaffolding of sorts. >>> >>> I know on some online forms there is a behavior where you can put in >>> something like a username or otherwise and it will populate a drop down box >>> with fields specific to that initial entry. Such as entering a "state" and >>> it limiting possible entries to "zip codes" within that state. >>> >>> I'm wondering if this is a place for jquery or if there is some other >>> method of doing this specific to flask and if someone could provide some >>> reference to an example. My google-fu has failed me. >>> >>> The only way I could think of doing it so far was to do an initial get >>> request using a submit button to populate the options but I think it would >>> be nicer to use Jquery. I have the database tables setup to support it, I >>> just need a way to pre-populate data for the fields based on a userid. >>> >>> Thanks! >>> >>> James >>> >> >
If you're going through full on front-end client stuff, you might want to checkout Backbone (with Backbone.Marionette if you want!). Similar in concept to AngularJS, but a different approach. I'm using it on several sites I've built. Or just dust.js for client-side templating if that's what you need. On Oct 3, 2012, at 1:32 PM, James Anderson wrote: > Thanks, > > I think AngularJS looks a little more on my level, other than it being a little kludgy. I'll take a look at both! > > On Wed, Oct 3, 2012 at 10:21 AM, Sean Lynch <techniq35@gmail.com> wrote: > You may also want to look at using AngularJS (angularjs.org). > > Here is a list of examples - https://github.com/angular/angular.js/wiki/JsFiddle-Examples > and a specific example on chained dropdowns - http://jsfiddle.net/KkdfV/35/ > > > On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com> wrote: > Use flask-sijax. Take a look at the examples. I would have provided actual code but I am on a mobile device. Sorry. > On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote: > Hello, > > I'm relatively new to web development in general and have been building an application in Flask using the Minitwit app as a scaffolding of sorts. > > I know on some online forms there is a behavior where you can put in something like a username or otherwise and it will populate a drop down box with fields specific to that initial entry. Such as entering a "state" and it limiting possible entries to "zip codes" within that state. > > I'm wondering if this is a place for jquery or if there is some other method of doing this specific to flask and if someone could provide some reference to an example. My google-fu has failed me. > > The only way I could think of doing it so far was to do an initial get request using a submit button to populate the options but I think it would be nicer to use Jquery. I have the database tables setup to support it, I just need a way to pre-populate data for the fields based on a userid. > > Thanks! > > James > >
Are you using WTF forms? - Joe Roszkowski On Oct 3, 2012, at 1:37 PM, Todd Kennedy <todd.kennedy@gmail.com> wrote: > If you're going through full on front-end client stuff, you might want to checkout Backbone (with Backbone.Marionette if you want!). > > Similar in concept to AngularJS, but a different approach. I'm using it on several sites I've built. > > Or just dust.js for client-side templating if that's what you need. > > On Oct 3, 2012, at 1:32 PM, James Anderson wrote: > >> Thanks, >> >> I think AngularJS looks a little more on my level, other than it being a little kludgy. I'll take a look at both! >> >> On Wed, Oct 3, 2012 at 10:21 AM, Sean Lynch <techniq35@gmail.com> wrote: >> You may also want to look at using AngularJS (angularjs.org). >> >> Here is a list of examples - https://github.com/angular/angular.js/wiki/JsFiddle-Examples >> and a specific example on chained dropdowns - http://jsfiddle.net/KkdfV/35/ >> >> >> On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com> wrote: >> Use flask-sijax. Take a look at the examples. I would have provided actual code but I am on a mobile device. Sorry. >> On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote: >> Hello, >> >> I'm relatively new to web development in general and have been building an application in Flask using the Minitwit app as a scaffolding of sorts. >> >> I know on some online forms there is a behavior where you can put in something like a username or otherwise and it will populate a drop down box with fields specific to that initial entry. Such as entering a "state" and it limiting possible entries to "zip codes" within that state. >> >> I'm wondering if this is a place for jquery or if there is some other method of doing this specific to flask and if someone could provide some reference to an example. My google-fu has failed me. >> >> The only way I could think of doing it so far was to do an initial get request using a submit button to populate the options but I think it would be nicer to use Jquery. I have the database tables setup to support it, I just need a way to pre-populate data for the fields based on a userid. >> >> Thanks! >> >> James >> >> >
I'm not, but looking at the documentation it looks like it makes things a little easier. Is there a straightfoward approach to this using it? On Wed, Oct 3, 2012 at 11:34 AM, Joey Roszkowski <joey2714@aol.com> wrote: > Are you using WTF forms? > > - Joe Roszkowski > > On Oct 3, 2012, at 1:37 PM, Todd Kennedy <todd.kennedy@gmail.com> wrote: > > > If you're going through full on front-end client stuff, you might want > to checkout Backbone (with Backbone.Marionette if you want!). > > > > Similar in concept to AngularJS, but a different approach. I'm using it > on several sites I've built. > > > > Or just dust.js for client-side templating if that's what you need. > > > > On Oct 3, 2012, at 1:32 PM, James Anderson wrote: > > > >> Thanks, > >> > >> I think AngularJS looks a little more on my level, other than it being > a little kludgy. I'll take a look at both! > >> > >> On Wed, Oct 3, 2012 at 10:21 AM, Sean Lynch <techniq35@gmail.com> > wrote: > >> You may also want to look at using AngularJS (angularjs.org). > >> > >> Here is a list of examples - > https://github.com/angular/angular.js/wiki/JsFiddle-Examples > >> and a specific example on chained dropdowns - > http://jsfiddle.net/KkdfV/35/ > >> > >> > >> On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com> > wrote: > >> Use flask-sijax. Take a look at the examples. I would have provided > actual code but I am on a mobile device. Sorry. > >> On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote: > >> Hello, > >> > >> I'm relatively new to web development in general and have been building > an application in Flask using the Minitwit app as a scaffolding of sorts. > >> > >> I know on some online forms there is a behavior where you can put in > something like a username or otherwise and it will populate a drop down box > with fields specific to that initial entry. Such as entering a "state" and > it limiting possible entries to "zip codes" within that state. > >> > >> I'm wondering if this is a place for jquery or if there is some other > method of doing this specific to flask and if someone could provide some > reference to an example. My google-fu has failed me. > >> > >> The only way I could think of doing it so far was to do an initial get > request using a submit button to populate the options but I think it would > be nicer to use Jquery. I have the database tables setup to support it, I > just need a way to pre-populate data for the fields based on a userid. > >> > >> Thanks! > >> > >> James > >> > >> > > >
To be honest, I'm not sure what the best fit would be. This is going to be used for a user management page. I have a table of users with multiple fields tied to them. We'll call it 'meta'. So User A has a Blue Hat, Red Hat, and Yellow Hat. On my user management page I currently query the 'user' table for all users in my user table for referencing purposes. I'm using this management page to select a user by ID from 'user', and I want to use that user ID to do a call back to 'meta' for all 'hats' that this user can wear. I then want to pre-populate a drop down list with the 'hats' so that I can make sure I can only select data available to a given user for posting new data to another table. In my mind this equates to the following process: Populate User_ID Field. -> Jquery (or manual post) call back to 'meta' table for * where user_id -> jinja filter to populate drop down box for x in 'meta' query. So if I can find a simple way to do it in Jquery that would be nice, but otherwise I am sure this can be done with a simple 'update' route that queries and has an endpoint back on my form. On Wed, Oct 3, 2012 at 10:37 AM, Todd Kennedy <todd.kennedy@gmail.com>wrote: > If you're going through full on front-end client stuff, you might want to > checkout Backbone (with Backbone.Marionette if you want!). > > Similar in concept to AngularJS, but a different approach. I'm using it > on several sites I've built. > > Or just dust.js for client-side templating if that's what you need. > > On Oct 3, 2012, at 1:32 PM, James Anderson wrote: > > > Thanks, > > > > I think AngularJS looks a little more on my level, other than it being a > little kludgy. I'll take a look at both! > > > > On Wed, Oct 3, 2012 at 10:21 AM, Sean Lynch <techniq35@gmail.com> wrote: > > You may also want to look at using AngularJS (angularjs.org). > > > > Here is a list of examples - > https://github.com/angular/angular.js/wiki/JsFiddle-Examples > > and a specific example on chained dropdowns - > http://jsfiddle.net/KkdfV/35/ > > > > > > On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com> > wrote: > > Use flask-sijax. Take a look at the examples. I would have provided > actual code but I am on a mobile device. Sorry. > > On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote: > > Hello, > > > > I'm relatively new to web development in general and have been building > an application in Flask using the Minitwit app as a scaffolding of sorts. > > > > I know on some online forms there is a behavior where you can put in > something like a username or otherwise and it will populate a drop down box > with fields specific to that initial entry. Such as entering a "state" and > it limiting possible entries to "zip codes" within that state. > > > > I'm wondering if this is a place for jquery or if there is some other > method of doing this specific to flask and if someone could provide some > reference to an example. My google-fu has failed me. > > > > The only way I could think of doing it so far was to do an initial get > request using a submit button to populate the options but I think it would > be nicer to use Jquery. I have the database tables setup to support it, I > just need a way to pre-populate data for the fields based on a userid. > > > > Thanks! > > > > James > > > > > >
Okay, just got back.
Yes, you can use jQuery. Sijax is a python library that allows you to pass
Ajax requests without having to take care about the rest of the things
deemed unnecessary. Flask-Sijax is merely an extension that allows you to
utilize the library. So if you were to have a form that has a field as per
your example:
<form method="POST" action="">
<label>Hats</label>
<input type="text" label="hats" name="hats" id="hats" />
<a href="javascript://" onclick="Sijax.request('pullallhats',
[$('#hats').value()]);>Get hats</a>
<!-- This will send a trigger to query all the results related to the
input field -->
</form>
In order to get the things to display beneath the field you will need
jQuery animation and stuff. That you need to look into on your own :)
But this has worked for me, I have done this before.
Oh I forgot the Python bit that will handle this request:
@flask_sijax.route('/foo')
def foo_handler():
def pull_hats_handler(obj_response, myhatinput):
#this is where you pull the hats from the database and update it
to your page
myhatsresult = db.query.get_results_for_hats_or_whatever()
return obj_response.script('') #this is where you pass the result
to the page using a script or a simple alert: e.g.
obj_response.alert(myhatsresult)
if g.sijax.is_sijax_request:
g.register_callback('pullallhats', pull_hats_handler)
return g.sijax.process_request()
return render_template('foo.html')
For more info: http://packages.python.org/Flask-Sijax/
On Thu, Oct 4, 2012 at 12:00 AM, James Anderson <jatroika@gmail.com> wrote:
> To be honest, I'm not sure what the best fit would be.
>
> This is going to be used for a user management page. I have a table of
> users with multiple fields tied to them. We'll call it 'meta'. So User A
> has a Blue Hat, Red Hat, and Yellow Hat. On my user management page I
> currently query the 'user' table for all users in my user table for
> referencing purposes. I'm using this management page to select a user by
> ID from 'user', and I want to use that user ID to do a call back to 'meta'
> for all 'hats' that this user can wear.
>
> I then want to pre-populate a drop down list with the 'hats' so that I can
> make sure I can only select data available to a given user for posting new
> data to another table.
>
> In my mind this equates to the following process:
>
> Populate User_ID Field. -> Jquery (or manual post) call back to 'meta'
> table for * where user_id -> jinja filter to populate drop down box for x
> in 'meta' query.
>
> So if I can find a simple way to do it in Jquery that would be nice, but
> otherwise I am sure this can be done with a simple 'update' route that
> queries and has an endpoint back on my form.
>
> On Wed, Oct 3, 2012 at 10:37 AM, Todd Kennedy <todd.kennedy@gmail.com>wrote:
>
>> If you're going through full on front-end client stuff, you might want to
>> checkout Backbone (with Backbone.Marionette if you want!).
>>
>> Similar in concept to AngularJS, but a different approach. I'm using it
>> on several sites I've built.
>>
>> Or just dust.js for client-side templating if that's what you need.
>>
>> On Oct 3, 2012, at 1:32 PM, James Anderson wrote:
>>
>> > Thanks,
>> >
>> > I think AngularJS looks a little more on my level, other than it being
>> a little kludgy. I'll take a look at both!
>> >
>> > On Wed, Oct 3, 2012 at 10:21 AM, Sean Lynch <techniq35@gmail.com>
>> wrote:
>> > You may also want to look at using AngularJS (angularjs.org).
>> >
>> > Here is a list of examples -
>> https://github.com/angular/angular.js/wiki/JsFiddle-Examples
>> > and a specific example on chained dropdowns -
>> http://jsfiddle.net/KkdfV/35/
>> >
>> >
>> > On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com>
>> wrote:
>> > Use flask-sijax. Take a look at the examples. I would have provided
>> actual code but I am on a mobile device. Sorry.
>> > On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote:
>> > Hello,
>> >
>> > I'm relatively new to web development in general and have been building
>> an application in Flask using the Minitwit app as a scaffolding of sorts.
>> >
>> > I know on some online forms there is a behavior where you can put in
>> something like a username or otherwise and it will populate a drop down box
>> with fields specific to that initial entry. Such as entering a "state" and
>> it limiting possible entries to "zip codes" within that state.
>> >
>> > I'm wondering if this is a place for jquery or if there is some other
>> method of doing this specific to flask and if someone could provide some
>> reference to an example. My google-fu has failed me.
>> >
>> > The only way I could think of doing it so far was to do an initial get
>> request using a submit button to populate the options but I think it would
>> be nicer to use Jquery. I have the database tables setup to support it, I
>> just need a way to pre-populate data for the fields based on a userid.
>> >
>> > Thanks!
>> >
>> > James
>> >
>> >
>>
>>
>
--
Regards,
Pronoy Chopra
http://blog.pronoy.in <http://www.pronoy.in/about>/
http://www.twitter.com/pronoyc
Wow, that is beautiful and is just what I'm looking for. Thank you so much! On Wed, Oct 3, 2012 at 11:54 AM, pronoyc@gmail.com <pronoyc@gmail.com>wrote: > Okay, just got back. > > Yes, you can use jQuery. Sijax is a python library that allows you to pass > Ajax requests without having to take care about the rest of the things > deemed unnecessary. Flask-Sijax is merely an extension that allows you to > utilize the library. So if you were to have a form that has a field as per > your example: > > <form method="POST" action=""> > <label>Hats</label> > <input type="text" label="hats" name="hats" id="hats" /> > <a href="javascript://" onclick="Sijax.request('pullallhats', > [$('#hats').value()]);>Get hats</a> > <!-- This will send a trigger to query all the results related to the > input field --> > </form> > > In order to get the things to display beneath the field you will need > jQuery animation and stuff. That you need to look into on your own :) > > But this has worked for me, I have done this before. > > Oh I forgot the Python bit that will handle this request: > > @flask_sijax.route('/foo') > def foo_handler(): > def pull_hats_handler(obj_response, myhatinput): > #this is where you pull the hats from the database and update it > to your page > myhatsresult = db.query.get_results_for_hats_or_whatever() > return obj_response.script('') #this is where you pass the > result to the page using a script or a simple alert: e.g. > obj_response.alert(myhatsresult) > > if g.sijax.is_sijax_request: > g.register_callback('pullallhats', pull_hats_handler) > return g.sijax.process_request() > > return render_template('foo.html') > > > For more info: http://packages.python.org/Flask-Sijax/ > > On Thu, Oct 4, 2012 at 12:00 AM, James Anderson <jatroika@gmail.com>wrote: > >> To be honest, I'm not sure what the best fit would be. >> >> This is going to be used for a user management page. I have a table of >> users with multiple fields tied to them. We'll call it 'meta'. So User A >> has a Blue Hat, Red Hat, and Yellow Hat. On my user management page I >> currently query the 'user' table for all users in my user table for >> referencing purposes. I'm using this management page to select a user by >> ID from 'user', and I want to use that user ID to do a call back to 'meta' >> for all 'hats' that this user can wear. >> >> I then want to pre-populate a drop down list with the 'hats' so that I >> can make sure I can only select data available to a given user for posting >> new data to another table. >> >> In my mind this equates to the following process: >> >> Populate User_ID Field. -> Jquery (or manual post) call back to 'meta' >> table for * where user_id -> jinja filter to populate drop down box for x >> in 'meta' query. >> >> So if I can find a simple way to do it in Jquery that would be nice, but >> otherwise I am sure this can be done with a simple 'update' route that >> queries and has an endpoint back on my form. >> >> On Wed, Oct 3, 2012 at 10:37 AM, Todd Kennedy <todd.kennedy@gmail.com>wrote: >> >>> If you're going through full on front-end client stuff, you might want >>> to checkout Backbone (with Backbone.Marionette if you want!). >>> >>> Similar in concept to AngularJS, but a different approach. I'm using it >>> on several sites I've built. >>> >>> Or just dust.js for client-side templating if that's what you need. >>> >>> On Oct 3, 2012, at 1:32 PM, James Anderson wrote: >>> >>> > Thanks, >>> > >>> > I think AngularJS looks a little more on my level, other than it being >>> a little kludgy. I'll take a look at both! >>> > >>> > On Wed, Oct 3, 2012 at 10:21 AM, Sean Lynch <techniq35@gmail.com> >>> wrote: >>> > You may also want to look at using AngularJS (angularjs.org). >>> > >>> > Here is a list of examples - >>> https://github.com/angular/angular.js/wiki/JsFiddle-Examples >>> > and a specific example on chained dropdowns - >>> http://jsfiddle.net/KkdfV/35/ >>> > >>> > >>> > On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com> >>> wrote: >>> > Use flask-sijax. Take a look at the examples. I would have provided >>> actual code but I am on a mobile device. Sorry. >>> > On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote: >>> > Hello, >>> > >>> > I'm relatively new to web development in general and have been >>> building an application in Flask using the Minitwit app as a scaffolding of >>> sorts. >>> > >>> > I know on some online forms there is a behavior where you can put in >>> something like a username or otherwise and it will populate a drop down box >>> with fields specific to that initial entry. Such as entering a "state" and >>> it limiting possible entries to "zip codes" within that state. >>> > >>> > I'm wondering if this is a place for jquery or if there is some other >>> method of doing this specific to flask and if someone could provide some >>> reference to an example. My google-fu has failed me. >>> > >>> > The only way I could think of doing it so far was to do an initial get >>> request using a submit button to populate the options but I think it would >>> be nicer to use Jquery. I have the database tables setup to support it, I >>> just need a way to pre-populate data for the fields based on a userid. >>> > >>> > Thanks! >>> > >>> > James >>> > >>> > >>> >>> >> > > > -- > Regards, > > Pronoy Chopra > http://blog.pronoy.in <http://www.pronoy.in/about>/ > http://www.twitter.com/pronoyc > >
The thing about obj_response.script() is that you can pass triggers with
the data to a predefined script on the page.
So if I had say a script that shows a menu beneath the field you can just
do this from the Python code
return obj_response.script('#script_id.show()')
subject to the condition that your script shows on show(). You can
experiment with Bootstrap's predefined scripts. It has a simple hide()
show() and toggle() predefined. I am sure you will find a dropdown if you
look through the latest version of Bootstrap, otherwise, it's easy to write
a simple script that shows a drop down having certain content.
Good Luck.
On Thu, Oct 4, 2012 at 12:34 AM, James Anderson <jatroika@gmail.com> wrote:
> Wow, that is beautiful and is just what I'm looking for. Thank you so much!
>
>
> On Wed, Oct 3, 2012 at 11:54 AM, pronoyc@gmail.com <pronoyc@gmail.com>wrote:
>
>> Okay, just got back.
>>
>> Yes, you can use jQuery. Sijax is a python library that allows you to
>> pass Ajax requests without having to take care about the rest of the things
>> deemed unnecessary. Flask-Sijax is merely an extension that allows you to
>> utilize the library. So if you were to have a form that has a field as per
>> your example:
>>
>> <form method="POST" action="">
>> <label>Hats</label>
>> <input type="text" label="hats" name="hats" id="hats" />
>> <a href="javascript://" onclick="Sijax.request('pullallhats',
>> [$('#hats').value()]);>Get hats</a>
>> <!-- This will send a trigger to query all the results related to the
>> input field -->
>> </form>
>>
>> In order to get the things to display beneath the field you will need
>> jQuery animation and stuff. That you need to look into on your own :)
>>
>> But this has worked for me, I have done this before.
>>
>> Oh I forgot the Python bit that will handle this request:
>>
>> @flask_sijax.route('/foo')
>> def foo_handler():
>> def pull_hats_handler(obj_response, myhatinput):
>> #this is where you pull the hats from the database and update
>> it to your page
>> myhatsresult = db.query.get_results_for_hats_or_whatever()
>> return obj_response.script('') #this is where you pass the
>> result to the page using a script or a simple alert: e.g.
>> obj_response.alert(myhatsresult)
>>
>> if g.sijax.is_sijax_request:
>> g.register_callback('pullallhats', pull_hats_handler)
>> return g.sijax.process_request()
>>
>> return render_template('foo.html')
>>
>>
>> For more info: http://packages.python.org/Flask-Sijax/
>>
>> On Thu, Oct 4, 2012 at 12:00 AM, James Anderson <jatroika@gmail.com>wrote:
>>
>>> To be honest, I'm not sure what the best fit would be.
>>>
>>> This is going to be used for a user management page. I have a table of
>>> users with multiple fields tied to them. We'll call it 'meta'. So User A
>>> has a Blue Hat, Red Hat, and Yellow Hat. On my user management page I
>>> currently query the 'user' table for all users in my user table for
>>> referencing purposes. I'm using this management page to select a user by
>>> ID from 'user', and I want to use that user ID to do a call back to 'meta'
>>> for all 'hats' that this user can wear.
>>>
>>> I then want to pre-populate a drop down list with the 'hats' so that I
>>> can make sure I can only select data available to a given user for posting
>>> new data to another table.
>>>
>>> In my mind this equates to the following process:
>>>
>>> Populate User_ID Field. -> Jquery (or manual post) call back to 'meta'
>>> table for * where user_id -> jinja filter to populate drop down box for x
>>> in 'meta' query.
>>>
>>> So if I can find a simple way to do it in Jquery that would be nice, but
>>> otherwise I am sure this can be done with a simple 'update' route that
>>> queries and has an endpoint back on my form.
>>>
>>> On Wed, Oct 3, 2012 at 10:37 AM, Todd Kennedy <todd.kennedy@gmail.com>wrote:
>>>
>>>> If you're going through full on front-end client stuff, you might want
>>>> to checkout Backbone (with Backbone.Marionette if you want!).
>>>>
>>>> Similar in concept to AngularJS, but a different approach. I'm using
>>>> it on several sites I've built.
>>>>
>>>> Or just dust.js for client-side templating if that's what you need.
>>>>
>>>> On Oct 3, 2012, at 1:32 PM, James Anderson wrote:
>>>>
>>>> > Thanks,
>>>> >
>>>> > I think AngularJS looks a little more on my level, other than it
>>>> being a little kludgy. I'll take a look at both!
>>>> >
>>>> > On Wed, Oct 3, 2012 at 10:21 AM, Sean Lynch <techniq35@gmail.com>
>>>> wrote:
>>>> > You may also want to look at using AngularJS (angularjs.org).
>>>> >
>>>> > Here is a list of examples -
>>>> https://github.com/angular/angular.js/wiki/JsFiddle-Examples
>>>> > and a specific example on chained dropdowns -
>>>> http://jsfiddle.net/KkdfV/35/
>>>> >
>>>> >
>>>> > On Wed, Oct 3, 2012 at 1:06 PM, pronoyc@gmail.com <pronoyc@gmail.com>
>>>> wrote:
>>>> > Use flask-sijax. Take a look at the examples. I would have provided
>>>> actual code but I am on a mobile device. Sorry.
>>>> > On Oct 3, 2012 10:28 PM, "James Anderson" <jatroika@gmail.com> wrote:
>>>> > Hello,
>>>> >
>>>> > I'm relatively new to web development in general and have been
>>>> building an application in Flask using the Minitwit app as a scaffolding of
>>>> sorts.
>>>> >
>>>> > I know on some online forms there is a behavior where you can put in
>>>> something like a username or otherwise and it will populate a drop down box
>>>> with fields specific to that initial entry. Such as entering a "state" and
>>>> it limiting possible entries to "zip codes" within that state.
>>>> >
>>>> > I'm wondering if this is a place for jquery or if there is some other
>>>> method of doing this specific to flask and if someone could provide some
>>>> reference to an example. My google-fu has failed me.
>>>> >
>>>> > The only way I could think of doing it so far was to do an initial
>>>> get request using a submit button to populate the options but I think it
>>>> would be nicer to use Jquery. I have the database tables setup to support
>>>> it, I just need a way to pre-populate data for the fields based on a userid.
>>>> >
>>>> > Thanks!
>>>> >
>>>> > James
>>>> >
>>>> >
>>>>
>>>>
>>>
>>
>>
>> --
>> Regards,
>>
>> Pronoy Chopra
>> http://blog.pronoy.in <http://www.pronoy.in/about>/
>> http://www.twitter.com/pronoyc
>>
>>
>
--
Regards,
Pronoy Chopra
http://blog.pronoy.in <http://www.pronoy.in/about>/
http://www.twitter.com/pronoyc