Sunday, November 4, 2012

CSS > Selector

w3Schools

CSS Selector Reference

http://www.w3schools.com/cssref/css_selectors.asp

element>elementdiv>pSelects all <p> elements where the parent is a <div> element2
element+elementdiv+pSelects all <p> elements that are placed immediately after <div> elements

[attribute][target]Selects all elements with a target attribute2
[attribute=value][target=_blank]Selects all elements with target="_blank"2
[attribute~=value][title~=flower]Selects all elements with a title attribute containing the word "flower"2
[attribute|=value][lang|=en]Selects all elements with a lang attribute value starting with "en"2
:linka:linkSelects all unvisited links1
:visiteda:visitedSelects all visited links1
:activea:activeSelects the active link1
:hovera:hoverSelects links on mouse over1
:focusinput:focusSelects the input element which has focus

jquery mobile forms validation

jquery mobile forms validation
http://stackoverflow.com/questions/5636856/jqm-jquerymobile-html5-form-validation
http://stackoverflow.com/questions/8997252/jquery-form-validation-in-jquery-mobile
http://www.elijahmanor.com/2011/02/jquery-mobile-form-validation.html





JQM (jQueryMobile) HTML5 Form Validation



Need to add form validation for each form and wanted to take advantage of the html5 syntax, that's why I liked the h5validate plugin but everything I try nothing happens, ugh...
I've also looked at the jQuery Validation plugin but the additional syntax and markup is something I'm trying to avoid. And I've looked at HTML5FORM but it is using jQuery 1.4.2 and I'm using 1.5.x
Wanted to know if anyone else had any luck with html5 and multi form validation submission?




A.

I have had success with multi forms with the validationEngine.js plugin from here http://www.position-relative.net/creation/formValidator/
Example here: http://coww.ws/jqmtest/
Hope this helps?

A2.
ValidVal is what I'm going with, it has all the simple syntax and takes advantage of the html5 attributes for validation



I'm trying to use form validation that is working in this example with my jQuery Mobile project:
This example works but uses an older version of jQuery Mobile js and css files. I'm working with the 1.0 release version which appears to have broken this form validation. You can see my updated version at:
You'll notice when you click the Login button you get the alert messages but they are not in red and are in the wrong location compared to the original version.
Can anyone locate what broke the original version and how to restore functionality to new version using jQuery Mobile 1.0?


Try this:




alternative to href="#" : to prevent href="#" link from jumping to top of page: function() { ...everything... return false; }

1
alternative to href="#" : to prevent href="#" link from jumping to top of page: function() { ...everything... return false; }

alternative to href="#"

Regarding "sending the user to the top of the page"; you should just return false from your the function you have hooked up as a click() handler;
$('a').click(function() {
    // Do your stuff.
    // The below line prevents the 'href' on the anchor to be followed.
    return false;
});




2
jquery getting the text of an element
http://api.jquery.com/text/



3


Simulating a click in jQuery/JavaScript on a link



$( 'selector for your link' ).click ();

http://stackoverflow.com/questions/1839363/simulating-a-click-in-jquery-javascript-on-a-link
http://api.jquery.com/click/




4

jquery prevent default on anchor

jQuery anchor preventDefault


http://stackoverflow.com/questions/3786898/jquery-anchor-preventdefault

jQuery('#demoLink').bind('click',function(e){
      e.preventDefault();
      document.location.href="someUrl.php?text="+ jQuery('#demoQuery').val();     
});




jquery.data(key, value)


jquery.data(key, value)

$('#something').data('foo', 52);        
alert($('#something').data('foo')); 


http://answers.oreilly.com/topic/1634-how-to-attach-objects-and-data-to-dom-with-jquery-data-to-avoid-memory-leak-issues/

How to attach objects and data to DOM with jQuery.data to avoid memory leak issues


Properties added to an object or DOM node at runtime (called expandos) exhibit a number of issues because of flawed garbage collection implementations in some web browsers. This excerpt from jQuery Cookbook shows you how to avoid memory leak issues by using .data().



css how to center a table?


how to center using css
MORE IMPORTANTLY,
css how to center a table?

container div, and table within.

<div id="price">
<table class="class-table-center">


/*** Center table in its container: .class ***/
table.class-table-center { /*** How to center align table in its container div. ***/
margin: auto;
}



http://webdesign.about.com/od/tables/qt/tiptablecenter.htm
http://www.granneman.com/webdev/coding/css/centertables/

http://www.w3.org/Style/Examples/007/center.en.html

CENTERING THINGS

A common task for CSS is to center text or images. In fact, there are three kinds of centering:


This small paragraph is vertically centered.

DIV.container {
    min-height: 10em;
    display: table-cell;
    vertical-align: middle }
...
<DIV class="container">
  <P>This small paragraph is vertically centered.
</DIV>













Using .data to attach (key,value) on any element, or jquery object

Using .data to attach (key,value) on any element, or jquery object
Purpose: To save data for later use, by callback functions
(e.g., knowing which control called this function, so that you know which control to update the text of)


$('#select-choice-custom-button').data('foo', 52); //place/save data
asdf = $('#select-choice-custom-button').data('foo') //retrieve/load data



CAVEAT:

//console.log($('#select-choice-custom-button').data()); //prints too many things; forgot to put a .data('keyname');



EXAMPLE USAGE:
$('#select-choice-custom-button').data('foo', 52);
alert($('#select-choice-custom-button').data('foo'));
console.log('ok');
 
   











jquery How to get the currently-selected TEXT inside a selectbox, not the value? (value is easy.)

jquery How to get the currently-selected TEXT inside a selectbox, not the value? (value is easy.)

to get the text:
http://stackoverflow.com/questions/1643227/jquery-get-selected-text-from-dropdownlist

$('#yourdropdownid').children("option:selected").text();
which is an optimization of

$("#yourdropdownid option:selected").text();






for completeness, to get the value:


<script>
var submit_product_edit_form = function() {
    // create a form hidden input with the value of true.
    $('<input>').attr({
        type: 'hidden',
        name: 'hidden_lang_change',
        value: true,
    }).appendTo('#product_view_form');

    // submit POST with it.
    $("#product_view_form").submit();
};

$("#id_lang").change(function() { // If Bulk Action selectbox OnChange
    submit_product_edit_form();
});
</script>



2

<script>
var submit_product_edit_form = function() {
    // create a form hidden input with the value of true.
    $('<input>').attr({
        type: 'hidden',
        name: 'hidden_lang_change',
        value: true,
    }).appendTo('#product_edit_form');

    // submit POST with it.
    $("#product_edit_form").submit();
};

$("#id_lang").change(function() { // If Bulk Action selectbox OnChange
    submit_product_edit_form();
});
</script>