Subversion Repositories SmartDukaan

Rev

Rev 25736 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
25721 tejbeer 1
$(function() {
2
	$(".focused_model").live('click', function() {
3
		loadModel("main-content");
4
	});
5
 
6
	$(".add-model").live(
7
			'click',
8
			function() {
9
				var catalogId = itemCatalogId;
10
				var recommended = $('#recommended').val();
11
				var minimumQty = $('#minimumQuantity').val();
12
 
13
				if (catalogId === null && recommended === ""
14
						&& minimumQty === "") {
15
					alert("Field can't be empty");
16
					return;
17
				}
18
 
19
				if (recommended === "") {
20
					alert("recommended quantity is required");
21
					return;
22
				}
23
				if (minimumQty === "") {
24
					alert("minimumQty is required");
25
					return;
26
				}
27
				if (catalogId === null) {
28
					alert("please choose item");
29
					return;
30
				}
31
				var params = {
32
					"catalogId" : catalogId,
33
					"recommended" : recommended,
34
					"minimumQty" : minimumQty
35
				}
36
				if (confirm("Are you sure you want to add item!") == true) {
37
					doPostAjaxRequestWithParamsHandler(context
38
							+ "/focusedModel", params, function(response) {
39
						alert("Add Item Successfully");
40
						loadModel("main-content");
41
					});
42
				}
43
			});
44
 
45
	$(".remove-model")
46
			.live(
47
					'click',
48
					function() {
49
						if (confirm("Are you sure you want to Remove the Item") == true) {
50
							catalogId = $(this).data('requestid');
51
							console.log(catalogId);
52
							doDeleteAjaxRequestHandler(context
53
									+ "/removeItem?catalogId=" + catalogId,
54
									function(response) {
55
										if (response == 'true') {
56
											alert("successfully Removed");
57
											loadModel("main-content");
58
										}
59
 
60
									});
61
						}
62
 
63
					});
64
});
65
 
66
function loadModel(domId) {
67
	doGetAjaxRequestHandler(context + "/getFocusedModel", function(response) {
68
		$('#' + domId).html(response);
69
	});
70
}