Subversion Repositories SmartDukaan

Rev

Rev 25721 | Rev 26281 | Go to most recent revision | Details | Compare with Previous | 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");
25736 tejbeer 4
 
5
		$("#focused-model-paginated .next").live(
6
				'click',
7
				function() {
8
					loadPaginatedNextItems('/getPaginatedFocusedModel', null,
9
							'focused-model-paginated', 'focused-model-table',
10
							'focused-model-container');
11
 
12
					$(this).blur();
13
				});
14
 
15
		$("#focused-model-paginated .previous").live(
16
				'click',
17
				function() {
18
 
19
					loadPaginatedPreviousItems('/getPaginatedFocusedModel', null,
20
							'focused-model-paginated', 'focused-model-table',
21
							'focused-model-container');
22
 
23
					$(this).blur();
24
				});
25
 
25721 tejbeer 26
	});
27
 
28
	$(".add-model").live(
29
			'click',
30
			function() {
31
				var catalogId = itemCatalogId;
32
				var recommended = $('#recommended').val();
33
				var minimumQty = $('#minimumQuantity').val();
34
 
35
				if (catalogId === null && recommended === ""
36
						&& minimumQty === "") {
37
					alert("Field can't be empty");
38
					return;
39
				}
40
 
41
				if (recommended === "") {
42
					alert("recommended quantity is required");
43
					return;
44
				}
45
				if (minimumQty === "") {
46
					alert("minimumQty is required");
47
					return;
48
				}
49
				if (catalogId === null) {
50
					alert("please choose item");
51
					return;
52
				}
53
				var params = {
54
					"catalogId" : catalogId,
55
					"recommended" : recommended,
56
					"minimumQty" : minimumQty
57
				}
58
				if (confirm("Are you sure you want to add item!") == true) {
59
					doPostAjaxRequestWithParamsHandler(context
60
							+ "/focusedModel", params, function(response) {
61
						alert("Add Item Successfully");
62
						loadModel("main-content");
63
					});
64
				}
65
			});
66
 
67
	$(".remove-model")
68
			.live(
69
					'click',
70
					function() {
71
						if (confirm("Are you sure you want to Remove the Item") == true) {
72
							catalogId = $(this).data('requestid');
73
							console.log(catalogId);
74
							doDeleteAjaxRequestHandler(context
75
									+ "/removeItem?catalogId=" + catalogId,
76
									function(response) {
77
										if (response == 'true') {
78
											alert("successfully Removed");
79
											loadModel("main-content");
80
										}
81
 
82
									});
83
						}
84
 
85
					});
86
});
87
 
88
function loadModel(domId) {
89
	doGetAjaxRequestHandler(context + "/getFocusedModel", function(response) {
90
		$('#' + domId).html(response);
91
	});
92
}