JQuery Autocomplete asp.net action not firing on select - select

Somehow action is not completed when I choose an item from the menu. Everything else works fine, except again - nothing happens when I select an item.
Here is the code:
<script type="text/javascript">
$(document).ready(function() {
$("#<%=txtSearchTerm.ClientID%>").autocomplete("Acc.ashx", {
formatItem: function(item) { return item.toString().split("#")[0]; },
formatResult: function(item) { return item.toString().split("#")[0]; },
select: function(event, ui) { alert('something'); }
});
});
</script>

I ended up with this working solution
<script type="text/javascript">
$(document).ready(function() {
$("#<%=txtSearchTerm.ClientID%>").autocomplete("Acc.ashx", {
formatItem: function(item) { return item.toString().split("#")[0]; },
formatResult: function(item) { return item.toString().split("#")[0]; }
});
$("#<%=txtSearchTerm.ClientID %>").result( function findValueCallback(event, data, formatted)
{
if(data)
{
$('#<%=hidOID.ClientID %>').val(data[0].toString().split('#')[1]);
}
});
});
</script>

Related

select2 doesn't show list in dialog modal

select2 is not showing the attended results. Actually it doesn't show anything at all. already tried to fix it removing tabindex in dialog. thanks for your help.
this is the result
view page dialog :
<div id="edit-interv" class="modal" role="dialog" title="Intervento" aria-hidden="true" style="overflow-y: hidden;">
view page select:
<select id="pippo" class="select_family form-control"></select>
footer page:
$('#edit-interv').open(function() {
$("#pippo").select2({
dropdownParent: $("#edit-interv"),
ajax: {
url: "{{basepath}}/fetchfamily",
dataType: 'json',
delay: 250,
data: function (term, page) {
return {
q: term,
page: page
};
},
processResults: function(data, params) {
return {
results: $.map(data, function(item) {
return {
text: item.name,
id: item.id
}
})
};
},
cache: true
},
minimumInputLength: 0
})
});

Pop Up form during page loads

I want to know how they make that pop up greeting during pages loads like on this wiredsystems page wired systems website
It is like a small form with a greeting on it.
Thank you!
Following is the script from page source of that site. In short, you call a pop-up function with $(document).ready.
require([
'jquery',
'jquery/jquery.cookie'
], function ($) {
$(document).ready(function(){
if($("body").hasClass("cms-index-index")) {
var check_cookie = $.cookie('newsletter_popup');
if(window.location!=window.parent.location){
$('#newsletter_popup').remove();
} else {
if(check_cookie == null || check_cookie == 'shown') {
setTimeout(function(){
beginNewsletterForm();
}, 1500);
}
$('#newsletter_popup_dont_show_again').on('change', function(){
if($(this).length){
var check_cookie = $.cookie('newsletter_popup');
if(check_cookie == null || check_cookie == 'shown') {
$.cookie('newsletter_popup','dontshowitagain');
}
else
{
$.cookie('newsletter_popup','shown');
beginNewsletterForm();
}
} else {
$.cookie('newsletter_popup','shown');
}
});
}
}
});
function beginNewsletterForm() {
$.fancybox({
'padding': '0px',
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'inline',
'href': '#newsletter_popup',
'onComplete': function() {
$.cookie('newsletter_popup', 'shown');
},
'tpl': {
closeBtn: '<a title="Close" class="fancybox-item fancybox-close fancybox-newsletter-close" href="javascript:;"></a>'
},
'helpers': {
overlay: {
locked: false
}
}
});
$('#newsletter_popup').trigger('click');
}
});

Extj 4 controller this.control listeners debounce?

How can I debounce listeners specified inside of controller using
this.control
?
Using the sample from the docs, you could use Ext.Function.defer() inside your
Ext.define('AM.controller.Users', {
init: function() {
this.control({
'useredit button[action=save]': {
click: function() {
//delay function call for a couple of seconds
Ext.Function.defer(this.updateUser, 2000, this);
}
}
});
},
updateUser: function(button) {
console.log('clicked the Save button');
}
});
Ext.define('AM.controller.Users', {
init: function() {
this.control({
'useredit button[action=save]': {
click: {
buffer:2000,
fn:this.updateUser
}
}
}
});
},
updateUser: function(button) {
console.log('clicked the Save button');
}
});

Modal open with angualrjs route

Hey I am working with bootstrap modal and calling it in angularjs. Its working good. Only the problem is that how can I route modal in angularjs routing. My Code:
Inside Controller
var modalInstance = $modal.open({
templateUrl: 'webpages/home/loginModal.html'
});
modalInstance.result.then(function () {
}, function () {
});
Inside Routing
.when('/login', {
templateUrl: function($routeParams) {
return 'sitepages/home/home.html';
},
controller: 'PageViewController',
reloadOnSearch: false
})
Its just example of routing how I am doing it, I need to find routing for modal.
You can use states for this purposes
$stateProvider.state("items.add", {
url: "/add",
onEnter: ['$stateParams', '$state', '$modal', '$resource', function($stateParams, $state, $modal, $resource) {
$modal.open({
templateUrl: "items/add",
resolve: {
item: function() { new Item(123).get(); }
},
controller: ['$scope', 'item', function($scope, item) {
$scope.dismiss = function() {
$scope.$dismiss();
};
$scope.save = function() {
item.update().then(function() {
$scope.$close(true);
});
};
}]
}).result.then(function(result) {
if (result) {
return $state.transitionTo("items");
}
});
}]
});
More details: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state
You don't need the routing for it
app.controller("ACtrl", ['$scope','$http', '$log', '$modal',
function($scope, http, $log, $modal){
$scope.OpenModel = function () {
var param = { appId: 1, price: 2.5 };
var modalInstance = $modal.open({
size: 'lg',
backdrop: 'static',
templateUrl: 'webpages/home/loginModal.html',
controller: 'modalCtrl',
resolve: {
data: function () { return param; }
}
});
modalInstance.result.then(function (response) {
//Do whatever you want to do with reponse
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
}
}
///Add your modal control here
app.controller("modalCtrl", ['$scope','$http', '$modalInstance', 'data',
function($scope, http, $modalInstance, data){
// rest of the code goes here
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}
}

Soundmanager 2 events won't fire/trigger

The soundmanager 2 events won't fire. Here is a snippet where the console.logs don't fire at all, therefore any of the different events aren't being triggered when they should.
soundManager.setup({
url: "js/swf/",
preferFlash: false,
useFlashBlock: false,
onready: function() {
soundManager.play(url, id, {
id: id,
url: url,
onplay: function() {
console.log("test");
},
onresume: function() {
console.log("test");
},
onpause: function() {
console.log("test");
},
onfinish: function() {
console.log("test");
next();
},
whileplaying: function() {
console.log("test");
},
});
},
defaultOptions: {
multiShotEvents: true, // allow events (onfinish()) to fire for each shot, if supported.
}
});
Is this because I have flash disabled? There is a bug currently where flash doesan't work in chrome.
Thanks.
You should use the
var sound = soundManager.createSound({id: 'soundId', url: '1.mp3'});
sound.play({
onplay: function() {
...
}
})
you missed "createSound"