how to write this piece of code in aspx page - events

Is it possible to write this line in aspx page on button client click event.
button.Attributes.Add("onclick", string.Format("postback(\"{0}\", \"\"); return false;", buttonSave.UniqueID));

Related

pass values between visualforce page salesforce

I have Custom Visual force page MyPage1 and on click of a button , I am calling /Apex/MyPage2 and also I am passing some input parameters as part of '/apex/MyPage2?accname={!Account.Name}&accid={!Account.Id}';
I am performing some activity in MyPAge2
and at the end, I want to returb back FinalVariable back to MyPage1
how I can pass back the response to calling VF page (MyPage1)?
please help
Communication between pages can be achieved using Javascript :
Listener() function in parent page.
Postmessage() function in chile page

crud trigger next button calendar

I have a site developed in crud with codeigniter.
I would when I enter into a determinate function in my view to trigger the button dhx_cal_next_button that goes on of a week for example.
I have tried but nothing succeed:
$('.dhx_cal_next_button').trigger('click');
I have seen that into the file dhtmlxscheduler.js there is this code (I have cut more code out this function):
scheduler._click={
dhx_cal_next_button:function(dummy,step){
scheduler.setCurrentView(scheduler.date.add( //next line changes scheduler._date , but seems it has not side-effects
scheduler.date[scheduler._mode+"_start"](scheduler._date),(step||1),scheduler._mode));
}
};
How can I simulate the click event on this button?
Thanks

jQuery Mobile: javascript breaks when after loading a page from ajax

So I've decided to use the jQuery Mobile framework to build my new mobile website. It has this feature of loading any local href link by ajax, which is great. But the new page that loads doesn't respond to any of the javascript. I've got a home page and page 2, both of which have the same html layout which a few changes in the content, I'll give an example.
I have made a navigation menu that slides in from the left and pushes the main content to the right. When I click on a page link, it loads the new page through ajax, but then on the new page, if I click the menu button, jQuery doesn't pick this up and so nothing happens (the menu doesnt slide out).
$(document).ready(function() {
$( ".menu-trigger" ).click(function() {
console.log("1")
if ($( 'nav' ).hasClass('navTransform')) {
console.log("2")
$( 'nav' ).removeClass('navTransform');
$( 'article' ).removeClass('articleTransform');
}
else {
console.log("3")
$( 'nav' ).addClass('navTransform');
$( 'article' ).addClass('articleTransform');
}
});
});
This jQuery script is in a seperate .js file thats included in the header of both the pages. I know the script works normally because when i refresh the page, the menu trigger works. Is there a known work around for this?
The workaround for this is to use appropriate jQM handler pageinit() instead of jQuery ready handler.
pageinit = DOM ready
One of the first things people learn in jQuery is to use the
$(document).ready() function for executing DOM-specific code as soon
as the DOM is ready (which often occurs long before the onload event).
However, in jQuery Mobile site and apps, pages are requested and
injected into the same DOM as the user navigates, so the DOM ready
event is not as useful, as it only executes for the first page. To
execute code whenever a new page is loaded and created in jQuery
Mobile, you can bind to the pageinit event.
So, your code might look like this:
$(document).on("pageinit", "#page1", function(){
//Your init code for page 1 goes here
});
$(document).on("pageinit", "#page2", function(){
//Your init code for page 2 goes here
});

Page Navigation while Ajax call in progress

In our application we are making an ajax call on the final submit button and displaying a modal dialog with progress bar in it. After successful processing the dialog will be updated with the response. Now my requirement is to change the modal dialog to non dialog and allow the user to navigate to another page while the ajax call gets finished.
What are the implications if i change the modal window to non modal window. Will the ajax call still continues or will it get aborted. if it continues will it have reference to the dialog to update it with the response.
Please let me know your views.
Whatever you do while your AJAX call is being made in terms of maniuplating the view, will not impact the AJAX call itself. As long as you let the AJAX call complete and show the changes on the callback, you will be okay.
Needless to say, you cannot change the actual page your on but if I understand you right, your not doing that anyway.
A simple experiment to try the idea
I've written a simple example where I have a HTML page with a link to another page. When I click that link, it sends an AJAX request to a PHP script that simulates a long process (wait 10 seconds) and then changes a variable in the session. The target page then echoes that variable.
When I click that link, the page starts a long AJAX request but it also navigates to another page. The result is that the AJAX request is cancelled and the other page prints "nothing".
Here's the server.php:
session_start();
$x = isset($_SESSION['x']) ? $_SESSION['x'] : 0;
sleep(10); /* simulates long process */
$_SESSION['x'] = ++$x;
echo $x;
index.html (the significant portion):
Click here
The AJAX request in index.html (inside a <script> tag):
document.querySelector('a').onclick = function(e) {
var xhr = new XMLHttpRequest();
xhr.onload = function(e) {
console.log(JSON.parse(xhr.responseText));
}
xhr.open('POST', 'server.php');
xhr.send();
}
Possible solution
If your request is time consuming on the server only, create an endpoint that returns the progress of that process, then add a javascript code in all your pages to consume this endpoint and show the progress to your user.

Maintaining a pop up after submitting the page

My client is using Magento, and after clicking the submit button, the form submits to the controller and then the same page reloads. What he asked me is once he clicks on the submit button he wants a popup displayed. So I used a div with a disabled background as a popup in a dynamic way (JavaScript), but since the button is "submitting", the page refreshes and I lose the popup, so is it possible to keep that div displayed even after submitting?
Jquery example:
$(document).ready(function(){
$('#form_selector').submit(function(){
showDialog();
//stop submit
return false;
});
$('#dialog_button_selector').click(function(){
//submit form
$('#form_selector').submit();
});
});
I'm not familiar with Magneto, but generally speaking, couldn't you look for a form submit in the controller when the page reloads and call for the popup, if true?
Why don't you use slide panel instead of pop-up panel?
For instance, check isLoggedin function of Magento :
<?php
if ($this->helper('customer')->isLoggedIn() ) {
echo "Welcome!";
} else {
echo "Please log in.";
}
?>
if customer is logged, show necessary information of customer inside the slide panel.
If you want just one time show this panel, try to event observer methods of magento :
app/code/core/Mage/Customer/Model/Session.php
Event names :
customer_login
customer_session_init
For jQuery Sliding Panel, you can use jqEasy which is supporting showOnLoad property.
jqEasy
Given that you don't want to hold submission of the page, you basically need to echo the popup after the page is submitted. So, using some generic event (catalog_product_add_to_cart_after), add a session variable like this:
public function observer($event) {
Mage::getSingleton("customer/session")->setNeedsCartPopup(true);
}
Then, in your template, you can check for the existence of this variable to show your popup:
$session = Mage::getSingleton("customer/session");
if($session->getNeedsCartPopup()) {
$session->->setNeedsCartPopup(false);
// echo HTML to display popup as the page loads
}
This is not tested code, but it should give you the gist of how to capture the event and respond to it in the template. Hope that helps!
Thanks,
Joe

Resources