Refreshing Only Favorites using Javascript - javascript

I have a Data Extender in place that modifies the Favorites' titles when ever favorites are requested. But when I add a single favourite, only that item is updated without calling the whole list. My question is how do I refresh only the favorites part in Tridion using JavaScript so that the entire favorites list is retrieved and the list is run through my data extender so that the title is updated.
So How do I refresh favorites only in Tridion using JavaScript?

$models.$cme.getShortcuts().getList().unload()

I don't have an instance open to test with, but in the PowerTools AddUser tool I refresh the main list using:
$display.getView().refreshList();
I imagine you can pass a view name to the function to specify which view you want to refresh.
The source for the tool command is at
http://code.google.com/p/tridion-2011-power-tools/source/browse/trunk/PowerTools.Editor/PowerTools/Client/AddUser/AddUserCommand.js

Related

Oracle Apex - Link to same page with values from selection lists

I'm trying to build up a link that includes three values from the choices of selection lists. It should point to the same page and reload it (page 11) while transferring the said values. By this, a chart is loaded which gets its data via pl sql query which is completed with the variables from the link. This works when having the link pointing to page 11 on another page (page 3). The values here are coming from an interactive report and the link ist generated via the link builder. When trying to reload the same page, it doesn't get the values from the choices of the selection lists. I guess it reads the values when the page is loaded and not dynamically, therefore they always stay empty. Is there an easy solution for this (perhaps using javascript)?
This is how the working link from Page3 to Page11 looks like:
/apex/f?p=&APP_ID.:11:'||:APP_SESSION||'::NO::CLASS,OBJECT,ATTRIBUTE:'||:P3_CLASS||','||:P3_OBJECT||','||:P3_ATTRIBUTE||'
It should be as simple as creating a button with action "Submit Page". This will submit the page and pick up the selected values.

How can i pass data from one HTML page to another using JavaScript

Im having a hard time passing data from one HTML page to another.
Im building an online store, i have one page with my items, and with their buttons for users to pick.
and i have seconde page that is my checkout page.
I want to make it so that when the user clicks on the items in the items page it will get written on the DOM on the checkout page.
2 main issues im having:
1 inside the javascript file i have for both pages, i have the variables and eventListerner for the buttons from the items page, and i also have the variable for the table in the checkout page where i want to write with the DOM.
When im on the items page, my table variable comes as null when console.log.
And when im on the checkout page i get:
itemsScript.js:44 Uncaught TypeError: Cannot read property 'addEventListener' of null
at addEventListeners (itemsScript.js:44)
at Array.map (<anonymous>)
at itemsScript.js:46
So i see that they are not comunicating properly.
2 where should i put the value and names of the items, on the buttons themself? maybe a data.js file, and the how could i get this data from the button that was clicked?
Is the checkout page a complete new site or implemented inside your product site?
In case of a complete new site you will trigger a new request. One way is using local storage/cache as one already mentioned. This would probably the best solution so you wont lose any items on a normal site reload.
In case of a implemtation direct on the product site have a look at ajax. This might help you.

Saving previous page parameters js, jsp

I'm currently working on one project which uses jsp, javascript, spring among others. I have a search page implemented where user can search by different criteria. (e.g. http://localhost:8080/service/timesheet/view?status=A&size=100&sort=startDate,asc&page=0&f_startDate_gte=2016-02-01&f_endDate_lte=2016-02-29)
When I click on some entry in this page I am redictered to the new page where a single item is shown. Now I want in this page to have a button which will bring me back to the search page but with the previous configured criterias. But the thing is that I can acces to those single item pages also from other points in application. What would be the best way to do this? Does it need to be done with passing parameters from jacaScript and checking out what was the previous visited page? Thank you for your help!
put it in user session object with a key that uniquely identify it. then you can make the decision based on that key/object pair.

Reload iframe content when session variable changes

I'm making a webshop for a school project, and i've got an issue with the shopping cart. because the shoppingcart & webshop are in different iframes on the main page(got quite a few images on main page, don't want to reload that, thats why it's in iframes).
Basically, my issue is that when something is selected in the webshop, the shopping cart doesn't update untill the entire webpage is reloaded. I'm storing shopping cart info in an array in a SESSION variable. basically, what i want is to reload the iframe of the cart when the session variable changes.
If the answer involves anything besides PHP/javascript, please give a clear explaination/example code, i've never used anything outside of PHP/js/html/css before. Thanks in advance :) been stuck on this for a few days now :S
Create a javascript function to fire the following code when a user adds something to their cart:
document.getElementById('some_frame_id').contentWindow.location.reload();
I don't have the code in front of me, but I've done something similar where in the parent you create an event listener on "message" then in the iframe you can call parent.postMessage, works as long as they are on the same domain
Although APAD1's answer directly addresses what you asked, it sounds like your program has some deeper design problems. Using iframes for content from the same site (ie within one domain rather than content from a separate site) is bad practice.
Consider instead displaying content in <div>s with unique ids, and using javascript to update the contents of those divs. If you're using PHP on the back end, you can create a "page" that only generates the cart contents part of your page. Not only can you include it in each page without changes, but you can load it directly with javascript and insert the result into the current page to update it in place.
Whenever your user adds an item to their cart, you can call the javascript method that refreshes the <div> with the cart's contents.

partial ajax update with back button

I'm doing partial update to the page with Ajax which is a shopping cart that updates with Ajax as users add items to it. The problem is that if users move to checkout and then hit the back button the shopping cart looks empty as it was updated with Ajax. Refreshing the page make items appear again.
Is there a way to force updating the page on back button?
If you use the history.pushstate in your ajax app, you can keep the contents of the card in a variable in the global namespace (e.g. window.cartItems = { item1, item2, ... }), and after back button is pressed and the previous button is rendered again, get your items from that global object.
I would recommend against altering the behavior of the back button itself. Users expect the Back button to take them back a page, not to do anything else.
I would suggest a different approach. For example, you could have a piece of JS that runs on the cart page itself. This script would grab all the cart data from the backend. The script could run once when the page loads, ensuring that the cart is up-to-date.

Categories