Page 1 of 2 12 LastLast
Results 1 to 15 of 27

Thread: How to refresh just one side of the page

  1. #1
    Join Date
    Dec 2012

    How to refresh just one side of the page

    See http://myownmealplanner.com/mealplans/add/5 for the example
    If you drag a meal tile to the right side of the page then it should stay there after you click on <a href="/mealplans/add">Go back to list of meal tiles</a> but of course it doesn't because the entire page gets refreshed. I tried adding an anchor for just the mealplan tiles (like a back to top button) but still the entire page gets refreshed. I can't think of any way to do this with jquery, javascript or php. Any ideas? You're supposed to be able to add tiles from the 500 calorie list and then for example the 300 cal list. Right now I only have 500 calorie tiles but you can see how it's supposed to work. This was made with the cakephp framework but it's principally the same as for a normal website.

  2. #2
    Join Date
    Dec 2012

    Multiple Ajax Requests with CakePHP

    If you start with http://myownmealplanner.com/mealplans/add/5 and click on the "100 cal tiles" div you get the ajax message "Request successful
    MEAL TILES" because of
    <div id="clickMe">100 cal tiles</div>
    <div id="result"></div>
    <script type="text/javascript">
    $("#clickMe").click(function() {
    The problem with Cakephp though is that it seems to have only one ajax.ctp file for all of the loads so I can't make 8 separate messages, one for each tile collection. How do I load for example the CTP called test without using the same ajax.ctp file as for the other ones? I need a separate ajax.ctp for every callback.

  3. #3
    Join Date
    Dec 2012
    I took the advice of Rasmus Lindström at http://www.devppl.com/forum/post71111.html#p71111 and used a GET variable to get different code for each ajax page but now the meal tiles aren't in the view source and thus aren't draggable.

  4. #4
    Join Date
    Dec 2012
    I was thinking maybe if I loaded an XML file with ajax I might be able to see it in view source but now I keep getting the error "failed to load external entity tiles.xml" Should I keep trying to create draggable divs with xml or am I on the wrong path here anyway?

  5. #5
    Join Date
    Dec 2012
    I got it to load the XML file but the XML doesn't show up in View Source either so I won't be able to use it.

  6. #6
    Join Date
    Dec 2012
    Here is the dilemma. If I use Ajax and even Ajax with an external XML source it doesn't show up in the view source so there's nothing to drag. If I use an iframe the draggable divs aren't on the same page as the droppable box. The last possibility would be sessions but how can I make sessions in the jquery drop function? The user would have to push some sort of button to get to the PHP.

  7. #7
    Join Date
    Nov 2010
    maybe a dumb question but:
    can't you just put the tiles and the list in hidden divs so that when you go "back" to the list of meal tiles you're not changing pages at all?

  8. #8
    Join Date
    Dec 2012
    I don't understand that at all. How would that work?

  9. #9
    Join Date
    Jun 2004
    Portsmouth UK
    you can change the content of the tile using AJAX not the tile its self

    if you change the whole Tile using AJAX it will not form part of the DOM and cannot be dragged

    God loves you and will never love you less.

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  10. #10
    Join Date
    Nov 2010
    I only did the 800 cal one, but you get the idea...
    <!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());
    	for (var i=1;i<100;i++){
            $( "#draggable" + i ).draggable();
            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>
    <!-- begin of draggable div-->
    <div id="meals800" class ="meals">
    800 Cal meals
    <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-->

  11. #11
    Join Date
    Dec 2012
    That looks like the best way to solve the problem but it involves a lot of work and I'm not ready to do it yet.

  12. #12
    Join Date
    Nov 2010
    it's not very much work at all - the functions are all in place, there's nothing else to add to the javascript. all you have to do is add the divs to the html with their correct classnames and IDs

  13. #13
    Join Date
    Dec 2012
    In my cakephp version the draggable divs come from the database so there's that to think about too. Thanks for your solution.

  14. #14
    Join Date
    Dec 2012
    The small peppermint mocha div can't be dragged. Maybe the show/hide functionality won't work after all.

  15. #15
    Join Date
    Dec 2012
    Never mind. Just needed to add $( "#draggable8" ).draggable(); in the jquery so that the peppermint mocha could be dragged after all.

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.15681 seconds
  • Memory Usage 3,027KB
  • Queries Executed 15 (?)
More Information
Template Usage (36):
  • (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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)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
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)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