Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    jzm
    jzm is offline
    New Coder
    Join Date
    Aug 2008
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Modernizr Load Issue

    Hello,

    I have installed Modernizr into my code to enable html5 placeholder support in firefox 3.6

    My issue is that because I am using a template structure (M.V.C) as my code base, I am unsure how I can get the "if()" script to work for my particular page as it would have to be called in the view. I have moved my modernizr script into my haeder -> was in my footer


    My Form:

    PHP Code:
     <?php
        
    //Setting form attributes
        
    $formAddSale = array('id' => 'addSale''name' => 'addSale');
        
    $saleName = array('id' => 'name''name' => 'name''placeholder' => 'Name*');
        
    $saleLocation = array('id' => 'location''name' => 'location''placeholder' => 'Location*');
        
    $saleBedrooms = array('id' => 'bedrooms','name' => 'bedrooms''placeholder' => 'Number of Bedrooms*');
        
    $holder' => 'Number of Bathrooms*');
        $saleCondition = array('
    id' => 'condition','name' => 'condition', 'placeholder' => 'Condition*');
        $saleImage = array('
    id' => 'userfile', 'name'=> 'userfile', 'placeholder' => 'File Location*');
        $saleDescription = array('
    id' => 'description','name' => 'description', 'placeholder' => 'Sale Description*');
        $salePrice = array('
    id' => 'price','name' => 'price', 'placeholder' => 'Price*');
        ?>

        <section id = "validation"><?php echo validation_errors();?></section>
        <?php 
        echo form_open_multipart('
    admin/addsale/', $formAddSale);
        echo form_fieldset(); 
        echo form_input($saleName);
        echo form_input($saleLocation);
        echo form_input($saleBedrooms);
        echo form_input($saleBathrooms);
        echo form_input($saleCondition);
        echo form_input($salePrice);
        echo form_upload($saleImage);
        echo form_textarea($saleDescription);
        echo form_submit('
    submit','Submit');
        echo form_fieldset_close();
        echo form_close();
        ?>saleBathrooms = array('
    id' => 'bathrooms','name' => 'bathrooms', 'place
    At the time of writing this question I have created a 'misc.js' document with the following code:

    Code:
        	// if placeholder isn't supported:
    	if (!Modernizr.input.placeholder){
    	  // use a input hint script
    		setInputHint(document.getElementById('name'),'Name*');
    		setInputHint(document.getElementById('location'),'Location*');
    		setInputHint(document.getElementById('bedrooms'),'Number of Bedrooms*');
    		setInputHint(document.getElementById('bathrooms'),'Number of Bathrooms*');
    		setInputHint(document.getElementById('condition'),'Condition*');
    		setInputHint(document.getElementById('price'),'Price*');
    		setInputHint(document.getElementById('description'),'Sale Description*');
    		setInputHint(document.getElementById('userfile'),'File Location*');
           }
    I have included the above document as you normally would in the footer of my "template"

    Code:
       <!-- jQuery Files --> 
        <script type="text/javascript"    src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> 
        <script type="text/javascript" src="http://www.domain.co.nz/includes/js/placeholder.js"></script> 
        <script type="text/javascript" src="http://www.domain.co.nz/includes/js/misc.js">    </script>

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Quote Originally Posted by jzm View Post
    I have installed Modernizr into my code to enable html5 placeholder support in firefox 3.6
    This won't work. Firefox 3.6 doesn't support the placeholder attribute, and Modernizr doesn't add any functionality, it just tests for support.

  • #3
    jzm
    jzm is offline
    New Coder
    Join Date
    Aug 2008
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by venegal View Post
    This won't work. Firefox 3.6 doesn't support the placeholder attribute, and Modernizr doesn't add any functionality, it just tests for support.
    Ok thanks, How would I make the jQuery placeholder work then, I through I needed Modernizr to work with the jQuery plugin.

    Jess

  • #4
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Sorry, I didn't read the whole thing before posting, and you are not actually doing what you said you were doing in the first line. Using Modernizr to test for support, and if it's missing, add it by using a jQuery plugin should be just fine.

    I don't see why you would have to place that snippet into the view; there's no problem with loading it up on every page, and just check if those ids actually exist before using them. Or give the body a class in your template, reflecting the page that's currently being viewed, which you can use in your Javascript logic.

    Of course, there isn't a real problem with placing the script in the view either (inside an onload or DOM-ready handler; those other scripts belong in the head anyway, so they will already be loaded). It won't be great for maintenance, though, so I wouldn't do that.

    Oh, and you might want to check if that placeholder plugin you are using doesn't already have a check for native support, in which case you wouldn't need Modernizr at all.


  •  

    Tags for this Thread

    Posting Permissions

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