Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27

Thread: How to refresh just one side of the page

  1. #16
    Join Date
    Nov 2010
    you would think that this code:
    for (var i=1;i<100;i++){
            $( "#draggable" + i ).draggable();
    would have taken care of that

    something I noticed: "clicking on the back to list" link hides the draggable divs (because they still "belong" to the divs on the left, even though they have been dragged. you may want to add these two lines to the drop function:

  2. #17
    Join Date
    Dec 2012
    I tried implementing the jquery toggle function for 300, 400, and 800 meal tiles but there is a problem when you toggle back and forth. If you try clicking on for example the 300 cal tiles and then dragging the tile to the right side you will see that if you click on it again that it will disappear from the right side as well.

  3. #18
    Join Date
    Nov 2010
    I can't see that happening. This code seems to work OK (only has the 300, 500 and 800 divs)...

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta name="keywords" content="meal planning, meals" />
    <meta name="description" content="recipes, cooking" />
    <meta name="robots" content="noindex,nofollow" />
    	<link rel="stylesheet" type="text/css" href="http://myownmealplanner.com/css/myownmealplanner.css" />
    	<link rel="stylesheet" type="text/css" href="http://myownmealplanner.com/css/fullcalendar.css" />
    	<script type="text/javascript" src="http://myownmealplanner.com/js/jquery-1.8.2.js"></script>
    	<script type="text/javascript" src="http://myownmealplanner.com/js/ui-1.9.1-jquery-ui.js"></script>
    <div id="container">
    <div id="header">
    <a href="/users"><img src="http://myownmealplanner.com/img/layout/indian_wedding.jpg" alt="My Own Meal Planner" id="main_pic" /></a></div>
    <div id="top_bar">
    <span class="top_tabs">
    <a href="/pages/home" class="menu_link">Steps</a></span>
    <span class="top_tabs">
    <a href="/mealplans/add" class="menu_link">Your Meal Planner</a></span>
    <span class="top_tabs">
    <a href="/mealplans" class="menu_link">Your Meal Plans</a></span>
    <span class="top_tabs">
    <a href="/calendars/navigate" class="menu_link">Your Meal Calendar</a></span>
    <span class="top_tabs">
    <a href="/users" class="menu_link">Register or Log In</a></span>
    <div id="home_page">
    <div id="meal_planner">
    <script type="text/javascript">
    $(document).ready(function() {
    	var selectedBoxes = new Array();
    	var total = 0;	
    	var userId = parseInt($('#MealplanUserId').val());
            drop: function(event, ui) {
    			var data = $(ui.draggable).attr('id');
    			for (var i=1;i<100;i++){
    		    if(data == "draggable" + i){
    			var myInt = parseInt($('#MealplanCalsPerServing' + i).val());
    		if ( typeof myInt === 'undefined' || !myInt) {
    		myInt = parseInt(0);
    		total += parseFloat(myInt);
           // Dropped out, remove it
           out: function( event, ui ) {
               var data = $(ui.draggable).attr('id');
               var sub;
               sub = $.inArray(data , selectedBoxes )
               if (sub >= 0) {
                   selectedBoxes.splice(sub, 1);
    			for (var i=1;i<100;i++){
    		    if(data == "draggable" + i){
    			var myInt = -($('#MealplanCalsPerServing' + i).val());
    		if ( typeof myInt === 'undefined' || !myInt) {
    		myInt = parseInt(0);
    		total += parseFloat(myInt);
    	$('#myId').click(function(event) {
            $.post("/mealplans/view", ({ data: selectedBoxes, userId: userId, total: total}), function(data, status) {
    		window.location = "/mealplans/view"
    	$('.plans').click(function() {
    	$('.back').click(function() {
    <h1>Meal Planner</h1>
    <br />
    <form action="/mealplans/view" id="MealplanViewForm" method="post" accept-charset="utf-8"><div style="display:none;"><input type="hidden" name="_method" value="POST"/></div>
    <br />
    <div id="draggables_box">
    <table id="tab" border="1" width="100%"><tr>
    <td><span class="plans" id="pl100">100 cal tiles</span></td>
    <td><span class="plans" id="pl200">200 cal tiles</span></td>
    <td><span class="plans" id="pl300">300 cal tiles</span></td>
    <td><span class="plans" id="pl400">400 cal tiles</span></td>
    <td><span class="plans" id="pl500">500 cal tiles</span></td>
    <td><span class="plans" id="pl600">600 cal tiles</span></td>
    <td><span class="plans" id="pl700">700 cal tiles</span></td>
    <td><span class="plans" id="pl800">800 cal tiles</span></td>
    <div id="meals300" class ="meals">
    300 cal meals
    <!-- begin of draggable div-->
    <div id="draggable5" class="draggable_meal">
    <div class="calorie_icon">330 CALS</div>
    <span>McDonald's cheeseburger</span>
    <input type="hidden" name="data[Mealplan][cals_per_serving5]" multiple="multiple" value="330" id="MealplanCalsPerServing5"/></div><!-- end of draggable div-->
    <!-- begin of draggable div-->
    <div id="draggable6" class="draggable_meal">
    <div class="calorie_icon">320 CALS</div>
    <span>large fries</span>
    <input type="hidden" name="data[Mealplan][cals_per_serving6]" multiple="multiple" value="320" id="MealplanCalsPerServing6"/></div><!-- end of draggable div-->
    <!-- begin of draggable div-->
    <div id="draggable7" class="draggable_meal">
    <div class="calorie_icon">280 CALS</div>
    <span>1/2 a bagel with cream cheese and jam</span>
    <input type="hidden" name="data[Mealplan][cals_per_serving7]" multiple="multiple" value="280" id="MealplanCalsPerServing7"/></div><!-- end of draggable div-->
    <span class="back">back to list</span>
    <div id="meals500" class ="meals">
    500 cal meals
    <!-- begin of draggable div-->
    <div id="draggable3" class="draggable_meal">
    <div class="calorie_icon">540 CALS</div>
    <span>Oatmeal with raisins, walnuts, and whole milk</span>
    <input type="hidden" name="data[Mealplan][cals_per_serving3]" multiple="multiple" value="540" id="MealplanCalsPerServing3"/></div><!-- end of draggable div-->
    <!-- begin of draggable div-->
    <div id="draggable2" class="draggable_meal">
    <div class="calorie_icon">510 CALS</div>
    <span>1 bag <em>Pop Secret Butter Popcorn</em></span>
    <input type="hidden" name="data[Mealplan][cals_per_serving2]" multiple="multiple" value="510" id="MealplanCalsPerServing2"/></div><!-- end of draggable div-->
    <!-- begin of draggable div-->
    <div id="draggable4" class="draggable_meal">
    <div class="calorie_icon">500 CALS</div>
    <span>4 dried figs (235 cals) + 15 macadamia nuts (265 cals)</span>
    <input type="hidden" name="data[Mealplan][cals_per_serving4]" multiple="multiple" value="500" id="MealplanCalsPerServing4"/></div><!-- end of draggable div-->
    <span class="back">back to list</span>
    <div id="meals800" class ="meals">
    800 Cal meals
    <!-- begin of draggable div-->
    <div id="draggable8" class="draggable_meal">
    <div class="calorie_icon">200 CALS</div>
    <span>Small Peppermint Mocha</span>
    <input type="hidden" name="data[Mealplan][cals_per_serving8]" multiple="multiple" value="200" id="MealplanCalsPerServing8"/></div><!-- end of draggable div-->
    <span class="back">back to list</span>
    <div style="float:right; margin-right: 6px;"><a href="javascript:location.reload(true)">RESET</a></div>
    <br style="clear: both;" />
    </div><!--end div for draggables_box -->
    <div id="droppable_box">
    <p>Drop a meal tile here.</p>
    <br style="clear: both;" />
    <div style="margin: 0px auto; width: 622px;">
    <p><b style="color: red;"></b></p>
    <br style="clear: both;" />
    <input type="hidden" name="data[Mealplan][user_id]" value="1" id="MealplanUserId"/>
    <input type="button" id="myId" name="myButton" value="Send Data" />
    </form><br />
    <a href="/users/logout">Logout</a></div>
    <br />
    </div><!--end div for meal_planner -->
    </div><!-- end of div home_page-->
    <br style="clear: both;" />
    <div id="footer">&copy; 2012 Maureen Moore</div>
    </div><!--end of container div-->

  4. #19
    Join Date
    Dec 2012

    Right side div doesn't obey jquery command

    I gave the draggable divs a new class called rightSide when they're dragged to the right side. You can see that the class has changed because the background color turns to pink. Now that it's a new class I can ask it to show instead of toggle like this:

    	$("#clickMe3").click(function() {
    But instead of showing the right side divs, it toggles back to hide just like the left side divs do. At http://myownmealplanner.com/mealplans/add you can click on the 300, 400, 800 tiles to try it out.

  5. #20
    Join Date
    Nov 2010
    I haven't looked at your code, but it sounds like you didn't read my advice back in post #16

    Quote Originally Posted by xelawho View Post
    something I noticed: "clicking on the back to list" link hides the draggable divs (because they still "belong" to the divs on the left, even though they have been dragged. you may want to add these two lines to the drop function:
    you seem to be creating near identical functions for every element. You should be aware that the real beauty of jQuery is that you can apply the same function to various elements using their class name.

    I'll say it once again: the code posted in 18 works fine. You seem to be trying to solve problems that don't actually exist.

  6. #21
    Join Date
    Dec 2012
    I added those two lines above so now it works but I still need to figure out why it works. This new code is a mystery to me.

  7. #22
    Join Date
    Nov 2010
    removes the draggable div from its original div on the left side and attaches it to the div on the right side (so that when the left hand div is hidden, the newly dropped div remains visible - because before, even though you dragged the div, it kept its position in the DOM)

    removes the weird inline css styling that you had for those divs - I think you changed it now, but before it was making them go way over to the right. You could probably remove this line.

  8. #23
    Join Date
    Dec 2012
    xelawho at http://www.webdeveloper.com/forum/sh...43#post1242743 suggested I use $(ui.draggable).appendTo($(this)); to keep the divs on the right side and now they don't hide when I toggle. It's pretty much working as desired now.

  9. #24
    Join Date
    Dec 2012


    Thanks for all of the useful input xelawho.

  10. #25
    Join Date
    Nov 2010
    You're very welcome. Glad you got it working. FWIW, I don't really like the way that the "previous" tiles remain visible when you click to see a new set, but I guess that's up to you.

  11. #26
    Join Date
    Dec 2012
    You have to click on the link again to make them disappear. Maybe I will change that some time so it's more intuitive but now I'm stuck on the calendar code. http://myownmealplanner.com/calendars/navigate If I delete the calendar css the right side of Saturdays seems to be the normal width but if it's there then the Saturdays are all squeezed together in one narrow column. I tried deleting css in steps to find out which css code is making it so narrow but I couldn't find it. I'm still working on it.

  12. #27
    Join Date
    Dec 2012
    The calendar was fixed by overwriting the jquery file with a newer one so that's taken care of now.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.10930 seconds
  • Memory Usage 2,995KB
  • Queries Executed 15 (?)
More Information
Template Usage (37):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (7)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (12)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (12)postbit
  • (12)postbit_onlinestatus
  • (12)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (74):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates