Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. event for partial view unload

event for partial view unload

Scheduled Pinned Locked Moved Web Development
helpdatabasequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Raghavendra Kodimala
    wrote on last edited by
    #1

    we're loading all partials views to a common div.

    $(divname).load(url);

    on clicking a row in a table or clicking on an icon,or clicking on link, view changes. my requirement is, in a partial view, we have two text boxes which are free type. before this view clears, i need to save these data to db. what appropriate event is to be used before this view goes? i tried

    $(document).unload
    $(document).unbind
    $(div).change
    $(div).unload

    etc. nothing worked. please help me to resolve this issue

    N 1 Reply Last reply
    0
    • R Raghavendra Kodimala

      we're loading all partials views to a common div.

      $(divname).load(url);

      on clicking a row in a table or clicking on an icon,or clicking on link, view changes. my requirement is, in a partial view, we have two text boxes which are free type. before this view clears, i need to save these data to db. what appropriate event is to be used before this view goes? i tried

      $(document).unload
      $(document).unbind
      $(div).change
      $(div).unload

      etc. nothing worked. please help me to resolve this issue

      N Offline
      N Offline
      Nathan Minier
      wrote on last edited by
      #2

      Write a little intermediary function and call your div updates using it

      var loadPartial = function(target, url, asyncPromise){
      if(asyncPromise){
      asyncPromise().done(function(){target.load(url)});
      }else{
      target.load(url);
      }
      }

      You can then update your values via AJAX safely before the div is loaded, or not pass a callback if that's not appropriate for a particular navigation. Using $(button).click for the save of ease, I don't know what your navigation event looks like.

      $(button).click(function(){
      loadPartial($(div),this.url,$.ajax({.../*update your database*/}));
      });

      It's not the prettiest thing, but it's flexible.

      "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups