How to get full path of selected file on change of using javascript, jquery-ajax? – Stack Overflow

$(‘#i_file’).change( function(event) { var tmppath = URL.createObjectURL(event.target.files[0]); $(“img”).fadeIn(“fast”).attr(‘src’,URL.createObjectURL(event.target.files[0])); $(“#disp_tmp_path”).html(“Temporary Path(Copy it and try pasting it in browser address bar) –> [“+tmppath+”]”);});

Source: How to get full path of selected file on change of using javascript, jquery-ajax? – Stack Overflow

Advertisements

#jquery, #stack-overflow

The ugly way to get twitter bootstrap in spring MVC

Ok, I know maven is great, but I am not able to work with it! You may call me a noob in spring and Java EE so it may be possible that I am not getting it properly, but here is an ugly way to enhance my page with bootstrap.

In servlet-context.xml, make sure this line exist

<resources mapping="/resources/**" location="/resources/" />

If it is already inside that xml file, you are lucky like me. Now download twitter bootstrap and put them in resources folder of your webapp folder.

if you have done it, then you can get bootstrap in your web view. try this

<script src="<c:url value="/resources/js/jquery.js" />"></script>
<script src="<c:url value="/resources/js/bootstrap.min.js" />"></script>
<link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/bootstrap.min.css" />" />

And then, do your design.

BTW, did i mention that you will need jquery to use bootstrap?

#bootstrap, #java-2, #java-web, #jquery, #spring-mvc

checking a checkbox in jquery

for JQuery 1.6+

$('.myCheckbox').prop('checked', true);
$('.myCheckbox').prop('checked', false);

for below 1.6

$('.myCheckbox').attr('checked', true);
$('.myCheckbox').attr('checked', false);

#checkbox, #code, #jquery

jquery-textfill/jquery-textfill · GitHub

jQuery TextFill resizes text to fit into a container and makes font size as big as possible.

This jQuery plugin was created by Russ Painter around May 2009, beginning with a StackOverflow question. In very early 2012, Yu-Jie Lin helped to move the project to GitHub with version 0.1 and obtained the clearly stated open source licensing from Russ.

via jquery-textfill/jquery-textfill · GitHub.

#jquery, #responsive, #text-fill

datepicker onchangemonthyear example (jquery UI)

<code>

$(“#datepicker”).datepicker({
onChangeMonthYear:function(year,month,instance){
console.log(year);
window.location.href=’index.php?venueId=1000&c=sales_dashboard&y=’+year+”&m=”+month;
}

}
);

</code>

#datepicker, #jquery, #jquery-ui, #snippet

jQuery onScrollBeyond and scrollExtend plugins

The scrollExtend plugin is designed to automatically load new content at the bottom of the screen (by appending to a DOM element) when the user scrolls beyond the element, much like Facebook does with their status updates. The existing infinite scroll plugin was primarily designed to integrate with WordPress, which didn’t really suit my purposes.

There are two plugins encapsulated here – onScrollBeyond, which allows the developer to specify a callback to be run when an element is scrolled beyond (or the end of the document is reached), and scrollExtend, which is simply an implementation of onScrollBeyond that automatically loads new content via ajax when a user scrolls past an element.

Works with jQuery 1.3.2 and jQuery 1.4.2

Tested in IE6, IE7, Firefox, Chrome, Safari

Update v1.0.1 – fixed scrollExtend would get stuck in a disabled state if beforeStart returned false, even if it returned true on subsequent calls

here how i used this,

</pre>
limit = 10;
 page = 0;

 $('#customersinfo').onScrollBeyond(function(){
 page=limit+page;
 $.post("tsz_analytics_controller.php?c=fetchCustomerInfo&venueId=<?php echo $_GET['venueId'] ?>&limit=" + limit + "&page=" + (page) + "", function(data) {
 $('#customersinfo').append(data);
 });

 });
<pre>

#ajax, #document-object-model, #javascript, #jquery, #scroll

jQuery.getScript()

 Load a JavaScript file from the server using a GET HTTP request, then execute it.

example:

$.getScript('ajax/test.js', function() {
    alert('Load was performed.');
});


http://api.jquery.com/jQuery.getScript/

http://stackoverflow.com/questions/2598469/jquery-how-to-include-other-js-files-into-js

#javascript, #jquery

Implementing jquery mobile in express js application with jade template

in layout.jade view file

doctype 5
html
         head
                 title= "MyMobileApp"
                 link(rel='stylesheet', href='/stylesheets/style.css')
                 link(rel='stylesheet', href='/stylesheets/jquery.mobile.css')
                 script(src='/javascripts/jquery.mobile.js')
                 script(src='/javascripts/jquery.js')
                 <meta name="viewport" content="width=device-width, initial-scale=1">
         body(class="ui-mobile-viewport ui-overlay-c")
                 div(data-role='page')
                 div(data-role='header',class='ui-header ui-bar-b')
                          h1 
                                   p My Sample Application
                 div(data-role='content',class='ui-content')
                          block content
                 div(data-role='footer',class='ui-header ui-bar-b')
                          h4= "Page Footer"

now, in index.jade view file,


extends layout

block content
p page content goes here

careful on indenting. jade template reacts the most with indentation.

#express-js, #jade, #jquery, #jquery-mobile, #mvc, #node-js, #template-engine

Manipulating checked box using jquery


$('#alldays').attr('checked','true'); // make the checked box true
 $('#alldaysAnyTime').attr('checked','true'); // another one example

#document-object-model, #jquery, #programming, #source-code

JQuery.trim() by example

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
 
<pre id="original"></pre>
<pre id="trimmed"></pre>
 
<script>
var str = " lots of spaces before and after ";
$("#original").html("Original String: '" + str + "'");
$("#trimmed").html("$.trim()'ed: '" + $.trim(str) + "'");
</script>
 
</body>
</html>
 
the syntax is $.trim(str)
 
taken from: http://api.jquery.com/jQuery.trim/

#client-side-development, #code, #example, #javascript, #jquery