I just noticed that this also happens in another view if I use a custom 
form. When I simply show the form as {{=form}} then jQuery does not cause 
the form to submit.. in that case, the js/jQuery code is inside a button 
that causes checkboxes to be selected on the page when the button is 
clicked. Not sure how to modulate this behavior..


On Monday, August 19, 2013 12:43:00 PM UTC-7, Jordan Ladora wrote:
>
> Hi,
>
> I'm trying to make div's in a view sortable. I initially tried  
>
> jQuery('div *').sortable()
>
> ..with no luck, and then tried the code below, using up and down buttons. 
> They work to move the content in the divs up or down, but clicking them 
> also causes form submission and page reload. I'm sure I'm missing 
> something, but I'd like to stop causing the page to reload when the up and 
> down buttons are clicked.
>
> Thanks for any help,
> -j
>
>
>
>
>
> {{extend 'layout.html'}}
>
> <script>src="http://code.jquery.com/jquery-1.7.2.min.js";></script>
>
> <script>
> jQuery(document).ready(function() {
>
>     jQuery('.up').click(function() {
>         var parent = jQuery(this).parent();
>         parent.insertBefore(parent.prev());
>         });
>
>     jQuery('.down').click(function() {
>         var parent = jQuery(this).parent();
>         parent.insertAfter(parent.next());
>         });
>
> });
> </script>
>
>
> {{=form.custom.begin}}
>
> <div id='a'>
>   <button class="up">Up</button>
>   <button class="down">Down</button>
>
>   {{=form.custom.widget.a}}
>
>   <div id='a1'>
>     {{=form.custom.widget.a1}}
>   </div>
> </div>
>
> <div id='b'>
>   <button class="up">Up</button>
>   <button class="down">Down</button>
>
>   {{=form.custom.widget.b}}
>
>   <div id='b1'>
>     {{=form.custom.widget.b1}}
>   </div>
> </div>
>
> <div id='c'>
>   <button class="up">Up</button>
>   <button class="down">Down</button>
>
>   {{=form.custom.widget.c}}
>
>   <div id='c1'>
>     {{=form.custom.widget.c1}}
>   </div>
> </div>
>
> Click here when ready: {{=form.custom.submit}}
>
> {{=form.custom.end}}
>
> <button name ="cancel_button" onclick = 
> 'window.location="{{=URL('mainhome')}}";'>Cancel</button>
>
>
> <div>
> request.vars
> {{=BEAUTIFY(request.vars)}}
> </div>
>
>

-- 

--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to