Showing posts with label element type. Show all posts
Showing posts with label element type. Show all posts

Tuesday, June 20, 2017

Angular/Ionic not updating an image src when ng-src is empty

The Angular ngSrc directive serves to properly set an image src via Angular. As anything in Angular, it updates the image as soon as the contained Angular expression changes. However, when the ng-src attribute is empty, Angular will not empty the src attribute. To overcome this, use the trick below.
<img ng-src="{{ element.image || '//:0' }}" />

Background

The ngSrc directive explicitly returns when the attribute value is false. As a workaround, set a "blank" image src when the image is empty. As somebody on Stackoverflow writes, //:0 serves this purpose: It adopts the current protocol, omits the hostname and sets the port to zero, which is invalid and should be killed by the network layer.
As a result, Angular should now correctly empty the src attribute when ng-src empties.


Thursday, February 12, 2015

Smooth Scroll Using jQuery

Smooth Scroll Using jQuery Code:


$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
});

Friday, August 9, 2013

Create Mathematical Validation in Phone

create input, box and operation div in the html file.
write below code in the js file.
var answer;

var method = ['+', '-', '*'];
var operation;
//var operation='1+2+3';

// load new operation on page laod
new_operation();

Wednesday, July 10, 2013

Get Element Attribute Value using jQuery

Create textarea element to enter html content dynamic

// button click
$('#click_elemtn').click(function(){
    var str= $('#html_content').text();
    html = $.parseHTML( str ); // parse text to html
    $.each( html, function( i, el ) {
        var attr = $(el).attr('src'); // attribute name that you want fro the textarea content
        if (typeof attr !== 'undefined' && attr !== false) {
            alert(attr); // attribute value
        }
    });
});

you can get attribute value in alert dialog.

refer below URL for live example

http://jsfiddle.net/RNmJ2/

Friday, April 19, 2013

Get County from User Lat Long

In Mobile application how the server knows about the posted device country and response then as per the location.

Get the current location of the device and use google map api to get user location. Get location from the ipaddress is a worth thing now. because all the internet user use proxy network.

PHP:

<?php

$cur_lat =$_REQUEST['lat'];
$cur_lon = $_REQUEST['lon'];

Stop Copy Text from Phonegap Applications

Hello,

Phonegap application is based on the HTML, CSS and JQuery. So if the user double tap on the app content then it will select the text and give option to copy and select text.

So for the application privacy if app admin does not want to copy application text then here is a way to stop selection of text.

Monday, March 19, 2012

Pass all the Form elements to call JSON


If you call any server file on the live server to get json data, then may be you need to transfer some variables with value. for ex. if you need to insert data to your server then you must haveto post all data to server file.

First you need to follow my previous blog(get-data-using-cross-domain-request).

Create one form element and create all the variable into the form tag that you want to post on the server.
Create below function in the .js file.

function createQuery(fname)
{
     var formname= fname;
     var elements = document.getElementById(formname).elements;
     var pairs = new Array();
var next_el = "";
var checkdetail=""
    for (var i = 0; i < elements.length; i++)
   {