SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unobtrusive Javascript

    I'm just learning the basics at the moment and alot of its going over my head.

    What I was wondering, I have two sets of prompts called via a class

    <a href="index.html" class="Delete"/class="Remove"

    Each one has a seperate pop up message (Are you sure you want to remove this, Are you sure you want to delete this from the database entirely)

    To accomplish this I made two sets of functions, however Im confident it can be done in one, but I'm too new to figure out the precise workings...so

    Code:
    function confirmDelete(event){
    
    if(confirm("Are you sure you want to delete this from the database entirely?")){
    	element = event.target;
    	deleteUrl = element.href;
    	window.location = deleteUrl;
      }
    }
    
    
    function bindDeleteConfs(){
      var els = $ES('a.Delete');
    
    for(var i=0;i<els.length;i++){
       els[i].addEvent('click', function(event){confirmDelete(event); event.preventDefault();}.bindWithEvent(els[i]));
      }
     }
    
    window.addEvent('domready', function(){ bindDeleteConfs() });
    
    
    
    function confirmRemove(event){
    
    if(confirm("Are you sure you want to remove this item from this?")){
    	element = event.target;
    	removeUrl = element.href;
    	window.location = removeUrl;
      }
    }
    
    
    function bindRemoveConfs(){
      var els = $ES('a.Remove');
    
    for(var i=0;i<els.length;i++){
       els[i].addEvent('click', function(event){confirmRemove(event); event.preventDefault();}.bindWithEvent(els[i]));
      }
     }
    
    window.addEvent('domready', function(){ bindRemoveConfs() });
    Help?

  2. #2
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yes and thats using the mootools framework

  3. #3
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anybody assist me with this?

  4. #4
    SiteP0int Weazle hooknc's Avatar
    Join Date
    Dec 2004
    Location
    Socialist Republic of Boulder
    Posts
    937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to ask your question in the JavaScript forum.
    baby steps... baby steps...

  5. #5
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,638
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    One better: moved to the JavaScript forum.

  6. #6
    SitePoint Zealot GiorgosK's Avatar
    Join Date
    Jun 2007
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suppose a mootools question should better be asked at the ...
    mootools forums http://forum.mootools.net/ ... it would have a faster response ...


Bookmarks

Posting Permissions

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